3340fd11ca
- Initialize Prisma with SQLite and Stock model - Create database service layer with singleton client - Add API routes for stock CRUD operations - Integrate database with analyze page to persist ticker entries - Add Playwright tests for stock database functionality
1.5 KiB
1.5 KiB
Prisma Stock Model Implementation Spec
Goal
Initialize Prisma ORM with SQLite database and create a Stock model to persist manually added stock tickers in the AITrader analyze route.
Architecture
- ORM: Prisma with SQLite datasource
- Database file:
prisma/dev.db - Model:
Stockwith id, ticker, optional notes, and timestamps - Integration: API routes for CRUD operations, integrated with analyze.tsx
Design Decisions
Stock Model Schema
model Stock {
id String @id @default(cuid())
ticker String @unique
notes String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
Rationale for notes field: Included for future extensibility (user notes on watched stocks). Nullable to avoid breaking changes.
Implementation Approach
- Single migration (
init) for all model fields - SQLite for development simplicity (matches plan)
- Prisma client singleton pattern for React Router 7 compatibility
Files to Create/Modify
Task 1: Initialize Prisma
prisma/schema.prisma- Prisma schema with Stock modelprisma/dev.db- SQLite database (generated)prisma/migrations/..._init/migration.sql- Initial migration (generated)
Success Criteria
prisma/schema.prismaexists with valid Stock modelnpx prisma generatecompletes without errorsnpx prisma migrate dev --name initcreatesprisma/dev.db- Git commit created with prisma/ changes
Dependencies to Install
prisma(dev dependency)@prisma/client(runtime dependency)