5 KiB
5 KiB
Project Overview
Name: Veridian Cultivation Platform Type: Full-stack SaaS application (backend + frontend) Primary Languages: TypeScript (Node.js 20, React 18) Status: v0.1.0, Internal Testing
High-Level Description
Veridian is a cultivation management platform for licensed cannabis facilities that centralizes:
- Grow Operations: Tasks, batches, rooms, and cultivation workflows
- Labor Tracking: Timeclock, hours, and cost-per-batch analysis
- Compliance: Document storage, audit packets, and METRC alignment
- Inventory: Materials, nutrients, and supplies with lot tracking
- Integrations: Environmental monitoring and hardware dashboards
- Communications: Task comments, announcements, and notifications
External Systems:
- PostgreSQL 15.x (primary database via Prisma ORM)
- METRC API (read-only in v1, California track-and-trace)
- SensorPush environmental sensors (via Veridian Edge agent)
- VPS deployment: nexus-vector
Multi-Repo Architecture
This repo works in conjunction with veridian-edge as a single codebase:
- veridian (this repo): Main platform backend + frontend
- veridian-edge: SensorPush edge agent that polls SensorPush Cloud API and syncs environmental readings to Veridian backend
When making changes, consider the API contract between these two repos:
- Edge agent → Veridian backend API endpoints
- Data models must match between edge agent and backend
- Authentication/authorization patterns
Layout
veridian/
├── backend/ # Express/Fastify backend API
│ ├── src/ # Source code
│ ├── prisma/ # Database schema and migrations
│ └── package.json # Node.js dependencies
├── frontend/ # React + Vite frontend
│ ├── src/ # Source code
│ └── package.json # Dependencies
├── docs/ # Architecture and compliance docs
├── specs/ # Feature specifications (Spec Kit workflow)
├── design-os/ # Design system components
└── docker-compose.yml # Local development stack
Conventions
Language/Style
- TypeScript strict mode enabled
- ESLint + Prettier for formatting
- Prisma 5.x for database access
- Conventional commits for git messages
Package Manager
- Use
buninstead ofnpmby default - Commands:
bun install,bun run,bun test,bun add
Error Handling
- Throw semantic errors with clear messages
- Use Result types for operations that can fail
- Never expose sensitive data in error messages
Logging
- Use structured logging (JSON in production)
- No
console.login production code - Log levels: error, warn, info, debug
Config
- Read from environment variables
- Never hard-code secrets or API keys
- Use
.env.exampleas template
Patterns & Playbooks
How to Add New API Endpoints
- Update Prisma schema if needed (
prisma/schema.prisma) - Run migration:
bunx prisma migrate dev --name description - Create route handler in
backend/src/routes/ - Add request validation (zod or similar)
- Implement business logic in service layer
- Add tests in
backend/src/__tests__/ - Update API documentation
How to Add New Frontend Components
- Create component in
frontend/src/components/ - Follow existing design system patterns (see
design-os/) - Use TypeScript with proper prop types
- Add responsive styles (Tailwind CSS)
- Create tests if component has logic
- Export from component index file
How to Write Database Migrations
- Modify
backend/prisma/schema.prisma - Run
bunx prisma migrate dev --name description - Generate client:
bunx prisma generate - For production:
bunx prisma migrate deploy
How to Run Locally
Backend:
cd backend
bun install
cp .env.example .env # Configure DB connection
bunx prisma migrate dev
bun run dev
Frontend:
cd frontend
bun install
cp .env.example .env # Configure API URL
bun run dev
Full Stack (Docker):
docker compose up -d
Important Environment Variables
DATABASE_URL: PostgreSQL connection stringJWT_SECRET: Secret for JWT token signingMETRC_API_KEY: METRC integration (read-only)SENSORPUSH_WEBHOOK_SECRET: Webhook verification for edge agent
PR & Learning Workflow
- When a PR introduces a new pattern or fixes a subtle issue:
- Summarize the lesson in 1-2 bullets
- Append under "Patterns & Playbooks" above
- Consider updating relevant documentation in
docs/
Testing Strategy
- Unit tests: Jest for pure functions and business logic
- Integration tests: API endpoint tests with test database
- E2E tests: Browser tests for critical flows (login, batch creation)
- VPS verification: After deployment, verify on nexus-vector
Compliance Notes
- METRC is system of record for California track-and-trace
- All compliance-relevant changes must be documented
- Audit logs must capture: who, what, when, for critical operations
- See
docs/compliance-notes-ca.mdfor detailed guidance