Production-style Node.js + TypeScript backend that provides a solid foundation for inventory and operations systems. It includes authentication, RBAC, auditing, and a clean, modular service layout to support real-world backend patterns.
Problem Solved This project standardizes core backend capabilities that inventory or operations platforms typically need: secure access, user management, auditing, and consistent API and validation patterns. It aims to reduce time-to-feature by shipping a stable, extensible base.
Tech Stack
- Node.js
- TypeScript
- Express
- PostgreSQL
- Prisma ORM
- JSON Web Tokens (JWT)
- bcrypt (password hashing)
- Zod (schema validation)
- express-session (session management)
- Helmet (security headers)
- express-rate-limit (basic rate limiting)
- ioredis (Redis client)
- Vitest + Supertest (tests)
Key Features
- Modular, feature-based routing under
src/modules - JWT access/refresh flow with refresh token rotation
- Session-based user attachment for server-side flows
- RBAC middleware (
ADMIN,STAFF,USER) - Request validation with Zod
- Centralized error handling and request logging
- Health check endpoint
- Audit log module
Project Structure
.
├── prisma/
│ └── schema.prisma
├── generated/
│ └── prisma/ # Prisma client output
├── src/
│ ├── app.ts # Express app wiring
│ ├── server.ts # App entry point
│ ├── config/ # env, prisma, redis, session
│ ├── middlewares/ # auth, rbac, validation, logging, rate-limit
│ ├── modules/ # feature modules
│ │ ├── auth/
│ │ ├── audit/
│ │ └── users/
│ ├── routes/ # API version routing
│ ├── types/ # Express type augmentation
│ ├── utils/ # shared helpers
│ └── __tests__/ # vitest tests
└── tsconfig.json
API Overview
GET /healthPOST /api/v1/auth/loginPOST /api/v1/auth/logoutPOST /api/v1/auth/mobile/loginPOST /api/v1/auth/mobile/refreshGET /api/v1/usersGET /api/v1/users/:idPOST /api/v1/usersGET /api/v1/audit-logs
Setup
- Install dependencies.
npm install- Configure environment variables.
Create a
.envfile with at least:
DATABASE_URL=postgresql://USER:PASSWORD@HOST:PORT/DB
JWT_ACCESS_SECRET=your-access-secret
JWT_REFRESH_SECRET=your-refresh-secret
SESSION_SECRET=your-session-secret
PORT=3000
NODE_ENV=development- Generate Prisma client.
npx prisma generate- Run database migrations (if you add migrations).
npx prisma migrate dev- Start the server.
npm run devScripts
npm run dev- run locally with ts-node-devnpm run build- compile TypeScript todist/npm start- run compiled servernpm test- run vitest suite
Notes
- Prisma schema lives at
prisma/schema.prisma. - The API is mounted under
/api/v1insrc/routes/v1.ts.