Skip to content

Backend Quick Start

Get the DoCurious Express server running locally in under five minutes.

STATUS: BUILT

The backend server is fully functional with 130+ endpoints, JWT authentication, and Prisma ORM.

Prerequisites

ToolMinimum VersionCheck
Node.js20+node -v
npm10+npm -v
PostgreSQL14+ (17 recommended)psql --version

Install

bash
cd server
npm install

Environment Setup

Copy the example environment file and edit as needed:

bash
cp .env.example .env

The .env file:

bash
# Database
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/docurious?schema=public"

# Server
PORT=8000
NODE_ENV=development

# JWT
JWT_SECRET="change-me-in-production"
JWT_REFRESH_SECRET="change-me-in-production-refresh"
JWT_ACCESS_EXPIRY="15m"
JWT_REFRESH_EXPIRY="7d"

# CORS — must match your frontend dev server
CORS_ORIGIN="http://localhost:5173"

# Cloudinary (file uploads — optional for local dev)
CLOUDINARY_CLOUD_NAME=""
CLOUDINARY_API_KEY=""
CLOUDINARY_API_SECRET=""

# Stripe (payments — optional for local dev)
STRIPE_SECRET_KEY=""
STRIPE_WEBHOOK_SECRET=""

All variables are validated at startup with Zod (server/src/config/env.ts). The server will exit with clear error messages if required variables are missing.

VariableRequiredDefaultNotes
DATABASE_URLYes--PostgreSQL connection string
PORTNo8000Server port
NODE_ENVNodevelopmentdevelopment, production, or test
JWT_SECRETYes--Access token signing key (min 10 chars)
JWT_REFRESH_SECRETYes--Refresh token signing key (min 10 chars)
JWT_ACCESS_EXPIRYNo15mAccess token lifetime
JWT_REFRESH_EXPIRYNo7dRefresh token lifetime
CORS_ORIGINNohttp://localhost:5173Comma-separated allowed origins
CLOUDINARY_*No""File upload CDN (optional)
STRIPE_*No""Payment processing (optional)

Database Setup

Make sure PostgreSQL is running, then generate the Prisma client and push the schema:

bash
npx prisma generate
npx prisma db push

To seed the database with sample data:

bash
npm run db:seed

To browse the database visually:

bash
npm run db:studio

NPM Scripts

ScriptCommandDescription
devnpm run devStart dev server with hot-reload (tsx watch)
buildnpm run buildCompile TypeScript to dist/
startnpm run startRun compiled production build
db:generatenpm run db:generateRegenerate Prisma client
db:pushnpm run db:pushPush schema changes to database
db:migratenpm run db:migrateCreate and run a migration
db:seednpm run db:seedSeed database with sample data
db:studionpm run db:studioOpen Prisma Studio GUI
testnpm run testRun test suite (Vitest)
test:watchnpm run test:watchRun tests in watch mode
test:reportnpm run test:reportRun tests and save report

Start the Dev Server

bash
npm run dev

The server starts at http://localhost:8000. Verify it's running:

bash
curl http://localhost:8000/api/portal/health

Expected response:

json
{
  "success": true,
  "data": {
    "status": "ok",
    "timestamp": "2026-02-14T...",
    "version": "0.2.0",
    "database": "docurious_prod"
  }
}

There is also a live HTML dashboard showing all endpoint implementation status at:

http://localhost:8000/api/portal/health/dashboard

Connecting the Frontend

To switch the frontend from mock APIs to the real backend:

  1. Edit the root .env file (not server/.env):
bash
VITE_USE_MOCK_API=false
VITE_API_URL=http://localhost:8000/api/portal
  1. Start both servers (in separate terminals):
bash
# Terminal 1 — Backend
cd server && npm run dev

# Terminal 2 — Frontend
npm run dev

The frontend's httpClient.ts will route all API calls through the Express server instead of the in-memory mock database.

Next Steps

DoCurious Platform Documentation