Skip to content

NB11B/wrm-platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WRM Platform - Backend

Well-Regulated Manufacturing coordination layer backend built with Next.js, Drizzle ORM, and PostgreSQL.

Tech Stack

  • 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

Project Structure

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

Getting Started

1. Install Dependencies

pnpm install

2. Set Up Environment Variables

Copy .env.example to .env.local and fill in your values:

cp .env.example .env.local

Required variables:

  • DATABASE_URL - PostgreSQL connection string
  • NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY - Clerk public key
  • CLERK_SECRET_KEY - Clerk secret key

3. Set Up Database

Create the database tables:

pnpm db:push

Or generate and run migrations:

pnpm db:generate
pnpm db:migrate

4. Run Development Server

pnpm dev

Open http://localhost:3000

Database Commands

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

Schema Overview

Core Entities

  • 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)

Job Flow

  • Jobs - Customer fabrication requests
  • JobFiles - Design files (STL, DXF, STEP, etc.)
  • JobQuotes - Bids from nodes
  • Reviews - Customer feedback

System

  • Notifications - User alerts and updates

API Routes (Planned)

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

Deployment

Vercel

  1. Connect GitHub repository to Vercel
  2. Add environment variables in Vercel dashboard
  3. Deploy

Database Setup

  1. Create a PostgreSQL database (Neon, Vercel Postgres, or Supabase)
  2. Copy connection string to DATABASE_URL
  3. Run pnpm db:push to create tables

Future Phases

Phase 2: Payments

  • Stripe Connect integration
  • Escrow and payouts
  • Transaction history

Phase 3: Maintenance Network

  • Machine health tracking
  • Maintenance request routing
  • Technician marketplace

Phase 4: OpenX Integration

  • Certification sync API
  • COLAB node registration
  • Training verification

Well-Regulated Manufacturing - The coordination layer for America's distributed industrial base.

About

Well-Regulated Manufacturing - Backend platform with Drizzle ORM, Next.js, and PostgreSQL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published