How arman-mishra562/jobzure-backend works
Project Type and Purpose
• JobZure Backend API: a standalone backend service (monolithic) written in TypeScript/Node.js with Express.
• Purpose: expose RESTful endpoints for user and admin workflows (authentication, two-factor, company listings, personal details) and persist data in PostgreSQL via Prisma ORM.
Key Architectural Components
• Client Layer (not in repo): frontend or third-party callers invoking HTTP endpoints over REST.
• API Layer (Express)
• src/index.ts: initializes Express server, middleware, routing prefix (/api/v1).
• src/routes/*.routes.ts: defines routes for admin, superAdmin, user.
• Controller Layer
• src/controllers/*.controller.ts: entry points for handling HTTP requests, invoking services, returning responses or errors.
• Service Layer
• src/services/*.ts: business logic (mail.service for email/2FA, rateLimit, user.cv generation).
• Schema & Validation
• src/schemas/*.schema.ts: Joi or Zod schemas for request payload validation.
• Data Access Layer (Prisma)
• prisma/schema.prisma: data model definitions.
• prisma/migrations: SQL scripts for versioned schema evolution.
• src/config/Db.ts: Prisma client setup and connection pooling.
• Auth & Security
• src/config/passport.ts: JWT strategy, two-factor auth flow.
• src/middlewares/middleware.ts: error handling, input sanitization, auth guard.
• Utilities
• src/utils/*.ts: shared helpers (asyncHandler, admin verification, user.mail2FA).
• External Services
• PostgreSQL database (hosted separately).
• Email provider (SMTP or transactional API).
• Infrastructure & Deployment
• Dockerfile: containerization.
• .env.example: environment variables (DB connection, JWT secrets, mail credentials).
Component Relationships and Data Flow
• Router delegates to Controller → Controller calls Service → Service uses Prisma client to read/write DB.
• Service may call External Service (email, 2FA SMS).
• Prisma client issues SQL to PostgreSQL.
• Responses propagate back up: DB → Service → Controller → Client.
Architectural Patterns & Principles
• Layered Architecture (Presentation → Controller → Service → Repository).
• Separation of Concerns (routing vs. business logic vs. data access).
• Single Responsibility (each controller/service focuses on one domain: user, admin, superAdmin).
• Token-based Authentication (JWT middleware).
• Two-Factor Authentication integration.
• Database migrations & seeding for consistency.