How olszarai/labelapp_backend works
Project type and purpose
• This is a monolithic backend RESTful API for “LabelApp” built with Node.js, Express.js, and TypeScript.
• Its purpose is to manage users, projects, and labels, exposing endpoints for registration, login, CRUD operations, and password reset.
File structure
• Top-level directories:
• prisma/ → database schema and migration scripts
• src/controllers/ → business logic per resource (User, Project, Label)
• src/routes/ → HTTP endpoint definitions
• src/middleware/ → JWT authentication middleware
• src/generated/prisma/ → auto-generated Prisma Client
• src/index.ts → Express server bootstrap
• Patterns:
• MVC: Models (Prisma schema), Views (not applicable – it’s an API), Controllers
• API routing layer → middleware → controllers → ORM client → database
• Config files: tsconfig.json, package.json, .gitignore
Extract architecture details from README
• MVC layers, Prisma ORM, JWT auth with HttpOnly cookies, bcrypt password hashing, nodemailer for email, PostgreSQL database
• Endpoints grouped by resource
Main components and their relationships
a. Clients
• Frontend or other API consumers
b. API Layer (Express Server)
1. Routing module (src/routes)
2. Middleware (src/middleware/authMiddleware.ts)
3. Controllers (src/controllers/*.ts)
4. Prisma Client (src/generated/prisma)
c. Database
• PostgreSQL with schema defined in prisma/schema.prisma
d. External Services
• SMTP server (nodemailer) for password reset emails
e. Environment & Config
• .env variables for DB, JWT secret, email credentials
Interaction flow
1. Client → HTTP Request → Express route
2. Route → authMiddleware (if protected)
3. Middleware → Controller
4. Controller → Prisma Client → PostgreSQL
5. Controller → Optional external call (SMTP) → nodemailer
6. Controller → Response → Client
Architectural patterns & design principles
• Layered MVC separation
• Dependency injection of Prisma client into controllers (via imports)
• Stateless JWT-based authentication
• Secure cookie storage (HttpOnly, SameSite)
• Migration-based schema evolution (Prisma migrations)
Detail-level checklist
• Prisma/schema.prisma as source of truth for data model
• JWT creation/verification step inside Middleware
• Environment variables driving DB connection and JWT secret