How webkawsar/express-prisma-app works
Main System Components
A. Authentication Layer
• Passport.js integration
• JWT token management
• Session management with express-session
• CSRF protection
B. API Layer
• Auth routes (signup, signin, verification, password reset)
• User management routes (CRUD operations)
• Role-based access control
C. Database Layer
• PostgreSQL database
• Prisma ORM interface
• Migration management
D. Security & Middleware Layer
• Authentication middleware
• Permission middleware
• Validation middleware
• CORS handling
[Client Requests]
• ↓
[Security Layer]
• CORS
• CSRF Protection
• Express Session
• ↓
[Authentication Layer]
• Passport Local Strategy
• JWT Token Management
• ↓
[API Routes Layer]
• Auth Routes
• User Routes
• ↓
[Controllers Layer]
• Auth Controller
• Users Controller
• ↓
[Middleware Layer]
• Validators
• Permission Checks
• Protection Middleware
• ↓
[Prisma ORM Layer]
• ↓
[PostgreSQL Database]
Important Elements to Highlight
A. Role-Based Access Control Flow:
• Admin → Full access to all users
• Support → Access to normal users
• Users → Self-management only
B. Authentication Flow:
• Local authentication with Passport.js
• JWT token generation and verification
• Session management
C. Data Flow:
• Request validation
• Permission checking
• Database operations through Prisma
Specific Implementation Details
• The MVC-like pattern (routes → controllers → models)
• The middleware chain sequence
• The role of Prisma as the database interface
• The security layers (CORS, CSRF, Session management)