How mdyhakash/prisma-press works
1. What this repo is
- This is a TypeScript Node.js backend API built around Prisma ORM and JWT-based authentication.
- The repository is organized as a small, feature-oriented server with two main domains: auth and user.
2. Application bootstrap
- src/server.ts is the process entrypoint: it starts the HTTP server.
- src/app.ts is the application assembly layer: it wires middleware, routes, and shared app-level configuration before the server listens.
3. Feature-module structure
- Business logic is split into modules under src/modules/.
- Each module follows the same shape:
- *.route.ts for endpoint definitions
- *.controller.ts for request/response handling
- *.service.ts for business logic and data access coordination
- *.interface.ts for module-specific TypeScript contracts
4. Auth subsystem
- src/modules/auth handles authentication concerns: likely login, token issuance, and related auth flows.
- It depends on:
- src/utils/jwt.ts for JWT creation/verification
- src/middlewares/auth.ts for protecting routes
- This makes auth a boundary that sits between public routes and protected application logic.
5. User subsystem
- src/modules/user encapsulates user-facing CRUD or profile-related operations.
- It is separate from auth, which suggests a clean split between identity/session management and user data operations.
6. Request flow
- Incoming requests go from route handlers to controllers, then to services.
- Services interact with the persistence layer through Prisma.
- Responses are normalized through src/utils/sendResponse.ts, and async errors are centralized via src/utils/catchAsync.ts.
7. Persistence layer
- src/lib/prisma.ts is the Prisma client singleton/connector used by services.
- The database model is defined in prisma/schema/ and evolved through prisma/migrations/.
- This means the application relies on Prisma as the only direct database boundary, rather than raw SQL in the app layer.
8. Schema organization
- Prisma schema is split into focused files:
- user.prisma
- profile.prisma
- enums.prisma
- schema.prisma
- That separation indicates the domain model is intentionally modular, with user/profile as core entities and enums extracted for reuse.
9. Configuration boundary
- src/config/index.ts centralizes environment/runtime configuration.
- prisma.config.ts handles Prisma-specific configuration outside the app runtime.
- This keeps deployment/runtime concerns separate from domain code.
10. Cross-cutting middleware and utilities
- src/middlewares/auth.ts is the primary request boundary for authorization.
- catchAsync.ts and sendResponse.ts standardize error handling and API output shape across modules.
- These utilities reduce duplication and keep controllers thin.
11. Documentation and ERD
- The README points to an ERD and includes an image in public/prisma-press-erd.jpg.
- The diagram is the source of truth for the data model, which is especially important here because the codebase is schema-driven through Prisma.
12. Overall architecture
- The system is a layered backend: HTTP layer → controller layer → service layer → Prisma/database.
- Its main architectural boundaries are:
- API transport (app.ts, server.ts, routes/controllers)
- Domain modules (auth, user)
- Persistence (lib/prisma.ts, Prisma schemas, migrations)
- Shared infrastructure (config, middleware, utils)
Main entry points: app.ts App · auth.controller.ts Auth Controller · user.controller.ts User Controller · prisma.ts Prisma Client
Components 17
Runtime/API
HTTP bootstrap and request handling layers
Features
Domain modules for auth and user operations
- Auth Routes · Authentication endpoints
src/modules/auth/auth.route.ts - Auth Controller · Handles auth requests and responses
src/modules/auth/auth.controller.ts - Auth Service · Auth business logic and token flow
src/modules/auth/auth.service.ts - User Routes · User endpoints
src/modules/user/user.route.ts - User Controller · Handles user requests and responses
src/modules/user/user.controller.ts - User Service · User business logic and persistence coordination
src/modules/user/user.service.ts
Infrastructure
Shared config, middleware, and utilities
- Auth Middleware · Protects authenticated routes
src/middlewares/auth.ts - JWT Utils · Signs and verifies JWTs
src/utils/jwt.ts - Async Wrapper · Centralized async error handling
src/utils/catchAsync.ts - Response Helper · Normalizes API responses
src/utils/sendResponse.ts - Config · Environment and app settings
src/config/index.ts
Persistence
Prisma client, schema, and migrations
- Prisma Client · Singleton database access layer
src/lib/prisma.ts - Prisma Schema · Domain schema split across Prisma files
prisma/schema/schema.prisma - Migrations · Database migration history
prisma/migrations/20260622092935_init/migration.sql - Prisma Config · Prisma tooling configuration
prisma.config.ts
Connections 19
- Server → App: bootstraps · Server starts the assembled application
- App → Auth Routes: mounts · App registers auth routes
- App → User Routes: mounts · App registers user routes
- Auth Routes → Auth Controller: invokes · Routes dispatch to controller handlers
- User Routes → User Controller: invokes · Routes dispatch to controller handlers
- Auth Controller → Auth Service: delegates · Controller forwards business logic to service
- User Controller → User Service: delegates · Controller forwards business logic to service
- Auth Service → JWT Utils: uses · Auth service issues and validates tokens
- Auth Routes → Auth Middleware: protects · Middleware gates authenticated endpoints
- Auth Controller → Async Wrapper: wraps · Async request handling is centralized
- User Controller → Async Wrapper: wraps · Async request handling is centralized
- Auth Controller → Response Helper: formats · Responses are standardized
- User Controller → Response Helper: formats · Responses are standardized
- Auth Service → Prisma Client: queries · Service reads/writes through Prisma
- User Service → Prisma Client: queries · Service reads/writes through Prisma
- Prisma Client → Prisma Schema: models · Client is generated from schema
- Prisma Client → Migrations: migrates · Database shape is tracked by migrations
- App → Config: reads · App loads runtime configuration
- Prisma Config → Prisma Schema: targets · Tooling is configured around the schema