How tausif-islam-sheik/hireiq-server works
1. Repository shape
This is a TypeScript/Node.js backend for HireIQ, built as an Express API server with a clear layered structure: routes → controllers → services → persistence/integrations. It is not the frontend; the frontend lives in a separate Next.js repo.
2. Primary runtime and deployment boundary
The server targets Node 20+, uses pnpm, and is designed for Render deployment (render.yaml, RENDER_DEPLOY.md). The app entry point is src/server.ts, with shared bootstrap/config concerns isolated from domain logic.
3. HTTP API layer
Each domain has its own route module under src/routes: auth, user, job, application, company, resume, savedJob, notification, and ai. These routes map requests to controller modules in src/controllers, keeping request handling separated by business area.
4. Controller orchestration layer
Controllers are the main orchestration boundary. They validate/shape incoming requests, enforce access rules via middleware, and delegate to services or AI modules. The controller set reflects the product’s core workflows: authentication, job management, application pipelines, resume handling, saved jobs, notifications, and AI features.
5. Core business services
The src/services directory holds the application’s business logic for auth, jobs, applications, saved jobs, notifications, email, and uploads. These services are the main boundary between HTTP/API concerns and infrastructure concerns, and they likely coordinate Prisma reads/writes plus external providers.
6. AI subsystem
AI logic is isolated under src/ai with focused modules for resume analysis, candidate ranking, interview coaching, and job-description generation. aiClient.ts is the central integration point for model/provider calls. The README indicates OpenRouter/OpenAI-style LLM usage, and the presence of jdGenerator, resumeAnalyzer, and interviewCoach shows the AI layer is used for recruitment-specific content generation and scoring, not generic chat.
7. Resume processing pipeline
Resume handling is split between parsing and AI analysis. src/lib/resumeParser.ts extracts text from uploaded documents, while the AI modules consume that parsed content for screening and quality analysis. This creates a distinct pipeline: file upload → text extraction → AI scoring/generation → persistence and/or user-facing results.
8. Persistence layer
PostgreSQL is the system of record, accessed through Prisma (prisma/schema.prisma, migrations under prisma/migrations, and src/lib/prisma.ts). The schema/migration history shows evolving recruitment data models, including saved jobs and user-state fields such as verification/activation. src/seed.ts suggests a bootstrap dataset for local/dev environments.
9. Background processing and caching
src/queues/emailQueue.ts and src/queues/resumeQueue.ts indicate asynchronous jobs for longer-running work, backed by Redis (src/lib/redis.ts). This separates latency-sensitive API requests from work such as resume processing and outbound email delivery. Even if the worker entrypoint is not visible in this tree, the architecture clearly treats these tasks as background work rather than inline request handling.
10. Realtime and notifications
src/socket/socket.ts adds a realtime channel, likely used to push status updates such as AI screening progress, application changes, or notification events to connected clients. Notification logic also has its own controller and service, which suggests a two-step pattern: persist notification state in the database and optionally broadcast updates over sockets.
11. Cross-cutting middleware
src/middleware contains the main request guards: JWT authentication, role-based authorization, rate limiting, and centralized error handling. These define the system’s security boundary and ensure domain controllers only see authenticated/authorized requests.
12. External infrastructure and integrations
The backend integrates with Cloudinary for file storage (src/lib/cloudinary.ts), Sentry for error monitoring (src/lib/sentry.ts), logging (src/lib/logger.ts), and Redis for queues/cache. The README also points to OpenRouter/LLM credentials in environment variables, making AI calls a first-class external dependency of the service.
13. How a typical request flows
A request enters Express, passes through auth/role/rate-limit middleware, hits a domain route, and reaches a controller. The controller then calls a service or AI module, which may read/write via Prisma, enqueue background work in BullMQ/Redis, upload files to Cloudinary, or emit realtime updates through Socket.io. That separation is the key architectural boundary in this repository.
Main entry points: server.ts Server · resume.controller.ts Resume Ctrl · aiClient.ts AI Client · prisma.ts Prisma
Components 32
Runtime
Process entrypoint and deployment boundary
- Server · Application bootstrap and process startup
src/server.ts
HTTP API
Routes and controllers for request handling
- Auth Routes · Auth endpoints and request wiring
src/routes/auth.routes.ts - User Routes · User-facing endpoints and request wiring
src/routes/user.routes.ts - Job Routes · Job endpoints and request wiring
src/routes/job.routes.ts - App Routes · Application workflow endpoints
src/routes/application.routes.ts - Company Routes · Company endpoints and request wiring
src/routes/company.routes.ts - Resume Routes · Resume upload and screening endpoints
src/routes/resume.routes.ts - Saved Routes · Saved-job endpoints and request wiring
src/routes/savedJob.routes.ts - Notify Routes · Notification endpoints and request wiring
src/routes/notification.routes.ts - AI Routes · AI feature endpoints and request wiring
src/routes/ai.routes.ts - Auth Ctrl · Authentication orchestration boundary
src/controllers/auth.controller.ts - Job Ctrl · Job management orchestration
src/controllers/job.controller.ts - Resume Ctrl · Resume upload and analysis orchestration
src/controllers/resume.controller.ts - Notify Ctrl · Notification orchestration and delivery
src/controllers/notification.controller.ts - Middleware · Auth, role, rate limit, and error handling
src/middleware/auth.middleware.ts
Core Logic
Business services and AI workflows
- Auth Service · Authentication and user session logic
src/services/auth.service.ts - Job Service · Job domain reads and writes
src/services/job.service.ts - App Service · Application pipeline business logic
src/services/application.service.ts - Notify Service · Notification persistence and dispatch logic
src/services/notification.service.ts - Upload Service · File upload and storage coordination
src/services/upload.service.ts - AI Client · Central model/provider call wrapper
src/ai/aiClient.ts - Resume AI · Resume screening and quality analysis
src/ai/resumeAnalyzer.ts - Ranker · Candidate scoring and ranking logic
src/ai/candidateRanker.ts - JD Generator · Job description generation
src/ai/jdGenerator.ts - Coach · Interview coaching and guidance
src/ai/interviewCoach.ts
Infrastructure
Persistence, storage, and external integrations
- Prisma · Typed PostgreSQL access layer
src/lib/prisma.ts - Cloudinary · External file storage integration
src/lib/cloudinary.ts - Redis · Redis connection for async work and caching
src/lib/redis.ts - Resume Parser · Extracts text from uploaded resumes
src/lib/resumeParser.ts
Async Work
Background queues and Redis-backed jobs
- Email Queue · Async outbound email jobs
src/queues/emailQueue.ts - Resume Queue · Async resume processing jobs
src/queues/resumeQueue.ts
Realtime
Socket channel for live updates
- Socket · Live server push and status updates
src/socket/socket.ts
Connections 37
- Server → Middleware: uses · Bootstrapped HTTP pipeline applies request guards
- Server → Auth Routes: mounts · Express mounts domain routes
- Server → User Routes: mounts · Express mounts domain routes
- Server → Job Routes: mounts · Express mounts domain routes
- Server → App Routes: mounts · Express mounts domain routes
- Server → Company Routes: mounts · Express mounts domain routes
- Server → Resume Routes: mounts · Express mounts domain routes
- Server → Saved Routes: mounts · Express mounts domain routes
- Server → Notify Routes: mounts · Express mounts domain routes
- Server → AI Routes: mounts · Express mounts domain routes
- Auth Routes → Auth Ctrl: calls · Route handlers delegate to controllers
- Job Routes → Job Ctrl: calls · Route handlers delegate to controllers
- Resume Routes → Resume Ctrl: calls · Route handlers delegate to controllers
- Notify Routes → Notify Ctrl: calls · Route handlers delegate to controllers
- Auth Ctrl → Auth Service: delegates · Controller orchestration passes into service layer
- Job Ctrl → Job Service: delegates · Controller orchestration passes into service layer
- Resume Ctrl → Upload Service: delegates · Uploads are handled by storage service
- Resume Ctrl → Resume Parser: parses · Uploaded documents are text-extracted before analysis
- Resume Ctrl → Resume Queue: enqueues · Long-running resume work is pushed async
- Notify Ctrl → Notify Service: delegates · Notification controller uses business service
- Auth Service → Prisma: reads/writes · Auth state is persisted in PostgreSQL via Prisma
- Job Service → Prisma: reads/writes · Job domain persistence
- App Service → Prisma: reads/writes · Application workflow persistence
- Notify Service → Prisma: reads/writes · Notification state persistence
- Upload Service → Cloudinary: stores · Files are uploaded to external storage
- Upload Service → Prisma: tracks · Stored file metadata can be persisted
- Resume Parser → Resume AI: feeds · Parsed resume text is analyzed by AI modules
- Resume AI → AI Client: calls · AI modules use central model client
- Ranker → AI Client: calls · AI modules use central model client
- JD Generator → AI Client: calls · AI modules use central model client
- Coach → AI Client: calls · AI modules use central model client
- AI Routes → AI Client: exposes · AI endpoints surface model-backed features
- Email Queue → Redis: backed by · Queue storage and delivery coordination
- Resume Queue → Redis: backed by · Queue storage and delivery coordination
- Notify Service → Socket: broadcasts · Notification updates may be pushed live
- Notify Service → Email Queue: queues · Outbound email delivery is asynchronous
- Resume Ctrl → Socket: updates · Resume processing status can be broadcast live