Well-Regulated Manufacturing coordination layer backend built with Next.js, Drizzle ORM, and PostgreSQL.
- Framework: Next.js 14 (App Router)
- Database: PostgreSQL (Neon/Vercel Postgres/Supabase)
- ORM: Drizzle ORM
- Auth: Clerk
- File Storage: Cloudflare R2 (S3-compatible)
- Hosting: Vercel
src/
├── app/ # Next.js App Router
│ ├── api/ # API routes
│ ├── (auth)/ # Auth pages (sign-in, sign-up)
│ ├── (dashboard)/ # Protected dashboard pages
│ └── (marketing)/ # Public marketing pages
├── db/
│ ├── schema/ # Drizzle schema definitions
│ │ ├── users.ts
│ │ ├── nodes.ts
│ │ ├── machines.ts
│ │ ├── materials.ts
│ │ ├── certifications.ts
│ │ ├── jobs.ts
│ │ ├── jobFiles.ts
│ │ ├── jobQuotes.ts
│ │ ├── reviews.ts
│ │ ├── notifications.ts
│ │ └── index.ts
│ └── index.ts # Database connection
├── lib/
│ ├── utils.ts # Utility functions
│ └── validations.ts # Zod schemas
└── components/ # React components
pnpm installCopy .env.example to .env.local and fill in your values:
cp .env.example .env.localRequired variables:
DATABASE_URL- PostgreSQL connection stringNEXT_PUBLIC_CLERK_PUBLISHABLE_KEY- Clerk public keyCLERK_SECRET_KEY- Clerk secret key
Create the database tables:
pnpm db:pushOr generate and run migrations:
pnpm db:generate
pnpm db:migratepnpm dev| Command | Description |
|---|---|
pnpm db:generate |
Generate migration files from schema changes |
pnpm db:migrate |
Run pending migrations |
pnpm db:push |
Push schema directly to database (dev only) |
pnpm db:studio |
Open Drizzle Studio for database browsing |
- Users - Customer and maker accounts
- Nodes - Maker shops with location and capabilities
- Machines - Equipment registered to nodes
- Materials - What each node can work with
- Certifications - Verified credentials (OpenX integration ready)
- Jobs - Customer fabrication requests
- JobFiles - Design files (STL, DXF, STEP, etc.)
- JobQuotes - Bids from nodes
- Reviews - Customer feedback
- Notifications - User alerts and updates
POST /api/nodes # Create node
GET /api/nodes # List/search nodes
GET /api/nodes/:id # Get node details
PATCH /api/nodes/:id # Update node
DELETE /api/nodes/:id # Delete node
POST /api/jobs # Create job
GET /api/jobs # List jobs
GET /api/jobs/:id # Get job details
PATCH /api/jobs/:id # Update job
POST /api/jobs/:id/quotes # Submit quote
POST /api/jobs/:id/accept # Accept quote
POST /api/files/upload # Upload design file
GET /api/files/:id # Get file download URL
- Connect GitHub repository to Vercel
- Add environment variables in Vercel dashboard
- Deploy
- Create a PostgreSQL database (Neon, Vercel Postgres, or Supabase)
- Copy connection string to
DATABASE_URL - Run
pnpm db:pushto create tables
- Stripe Connect integration
- Escrow and payouts
- Transaction history
- Machine health tracking
- Maintenance request routing
- Technician marketplace
- Certification sync API
- COLAB node registration
- Training verification
Well-Regulated Manufacturing - The coordination layer for America's distributed industrial base.