chore: add debug script
This commit is contained in:
parent
d294f1746f
commit
afe00b3c45
4 changed files with 208 additions and 1 deletions
152
.claude/claude.md
Normal file
152
.claude/claude.md
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
# 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 `bun` instead of `npm`** by 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.log` in production code
|
||||
- Log levels: error, warn, info, debug
|
||||
|
||||
### Config
|
||||
- Read from environment variables
|
||||
- Never hard-code secrets or API keys
|
||||
- Use `.env.example` as template
|
||||
|
||||
## Patterns & Playbooks
|
||||
|
||||
### How to Add New API Endpoints
|
||||
1. Update Prisma schema if needed (`prisma/schema.prisma`)
|
||||
2. Run migration: `bunx prisma migrate dev --name description`
|
||||
3. Create route handler in `backend/src/routes/`
|
||||
4. Add request validation (zod or similar)
|
||||
5. Implement business logic in service layer
|
||||
6. Add tests in `backend/src/__tests__/`
|
||||
7. Update API documentation
|
||||
|
||||
### How to Add New Frontend Components
|
||||
1. Create component in `frontend/src/components/`
|
||||
2. Follow existing design system patterns (see `design-os/`)
|
||||
3. Use TypeScript with proper prop types
|
||||
4. Add responsive styles (Tailwind CSS)
|
||||
5. Create tests if component has logic
|
||||
6. Export from component index file
|
||||
|
||||
### How to Write Database Migrations
|
||||
1. Modify `backend/prisma/schema.prisma`
|
||||
2. Run `bunx prisma migrate dev --name description`
|
||||
3. Generate client: `bunx prisma generate`
|
||||
4. For production: `bunx prisma migrate deploy`
|
||||
|
||||
### How to Run Locally
|
||||
**Backend:**
|
||||
```bash
|
||||
cd backend
|
||||
bun install
|
||||
cp .env.example .env # Configure DB connection
|
||||
bunx prisma migrate dev
|
||||
bun run dev
|
||||
```
|
||||
|
||||
**Frontend:**
|
||||
```bash
|
||||
cd frontend
|
||||
bun install
|
||||
cp .env.example .env # Configure API URL
|
||||
bun run dev
|
||||
```
|
||||
|
||||
**Full Stack (Docker):**
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
### Important Environment Variables
|
||||
- `DATABASE_URL`: PostgreSQL connection string
|
||||
- `JWT_SECRET`: Secret for JWT token signing
|
||||
- `METRC_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:
|
||||
1. Summarize the lesson in 1-2 bullets
|
||||
2. Append under "Patterns & Playbooks" above
|
||||
3. 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.md` for detailed guidance
|
||||
31
.claude/commands/deploy-vps.md
Normal file
31
.claude/commands/deploy-vps.md
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
You are the VPS deployment assistant for Veridian.
|
||||
|
||||
## VPS Information
|
||||
- Host: nexus-vector
|
||||
- User: admin
|
||||
- Project path on VPS: /home/admin/honkingversion (adjust if different)
|
||||
|
||||
## Deployment Process
|
||||
|
||||
1. **Pre-deployment checks**:
|
||||
- `git status` to check for uncommitted changes
|
||||
- `git log -1 --oneline` to show what will be deployed
|
||||
|
||||
2. **Deploy to VPS**:
|
||||
```bash
|
||||
ssh admin@nexus-vector 'cd /home/admin/honkingversion && git pull origin master && docker compose down && docker compose up -d --build 2>&1 | tail -50'
|
||||
```
|
||||
|
||||
3. **Post-deployment verification**:
|
||||
- Check service status: `ssh admin@nexus-vector 'docker compose ps'`
|
||||
- View logs: `ssh admin@nexus-vector 'docker compose logs --tail 50'`
|
||||
- Health check: `curl https://your-veridian-url.com/health` (if available)
|
||||
|
||||
## Output
|
||||
|
||||
Report:
|
||||
- What was deployed (commit hash, message)
|
||||
- Docker build output summary
|
||||
- Service status (running/not running)
|
||||
- Any errors or warnings in logs
|
||||
- Suggested manual verification steps (URLs to check, flows to test)
|
||||
24
.claude/commands/migrate.md
Normal file
24
.claude/commands/migrate.md
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
You are the database migration assistant for Veridian.
|
||||
|
||||
## Process
|
||||
|
||||
1. **Check current state**:
|
||||
- `cd backend && bunx prisma migrate status`
|
||||
- Show any pending migrations
|
||||
|
||||
2. **Create migration**:
|
||||
- Ask for a description of the schema change
|
||||
- Run: `cd backend && bunx prisma migrate dev --name description`
|
||||
- Generate Prisma client: `bunx prisma generate`
|
||||
|
||||
3. **Verify**:
|
||||
- Show the generated SQL
|
||||
- Check if any data migration is needed
|
||||
|
||||
## Output
|
||||
|
||||
Report:
|
||||
- Migration name and number
|
||||
- SQL changes summary
|
||||
- Whether data migration is needed
|
||||
- Next steps (deploy to production, etc.)
|
||||
|
|
@ -108,7 +108,7 @@ export default function Layout() {
|
|||
<PageTitleUpdater />
|
||||
<AnnouncementBanner />
|
||||
|
||||
<div className="max-w-[1920px] mx-auto p-4 sm:p-6 lg:p-8">
|
||||
<div className="max-w-[1920px] mx-auto p-4 pb-24 sm:p-6 sm:pb-24 md:pb-8 lg:p-8">
|
||||
<Breadcrumbs />
|
||||
|
||||
<AnimatePresence mode="wait">
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue