How shreysoni1102-cell/hirehub works
1. Overall shape
This is a three-part monorepo: a React/Vite frontend in client/, an Express/MongoDB API in server/, and a separate Python AI service in ai-service/. The core architecture boundary is browser UI → REST API → MongoDB, with AI-related features split off into their own service layer.
2. Frontend subsystem
The client/ app is a single-page application built with React 18, Vite, Tailwind CSS, React Router v6, and Axios. Its job is presentation, navigation, and session state, not business logic. Key shared UI pieces live in components/ (Navbar, Layout, ProtectedRoute), while page-level features are organized under pages/ for home, auth, dashboards, job detail, applications, chat, and ATS checking.
3. Client-side state and access control
Authentication state is managed in context/AuthContext.jsx, and theme state in context/ThemeContext.jsx. JWTs and the current user snapshot are stored in localStorage, then reused by Axios for authenticated requests. ProtectedRoute enforces route-level access and can gate pages by role, which keeps the role-specific views separated in the UI.
4. Frontend-to-backend integration
The frontend calls the API through client/src/api/axios.js. In development, it relies on the Vite proxy so /api routes reach the backend on port 5000; in production it can point to a deployed API root via VITE_API_URL. Every request includes Authorization: Bearer <token> when present, so the server remains the source of truth for authorization.
5. Backend entry and structure
The backend starts from server/server.js and follows an MVC-style layout: config/, controllers/, middleware/, models/, routes/, and utils/. This makes the API the central orchestration layer: routes dispatch to controllers, controllers apply business rules, models map to MongoDB, and utilities handle cross-cutting concerns like JWT generation and email/AI helpers.
6. Authentication and role model
Authentication is based on JWT and password hashing with bcrypt. The User model stores credentials and role information, and auth middleware (protect, role.js) enforces access by role: admin, recruiter, and user/job seeker. Public registration is restricted to non-admin roles; admin accounts are expected to come from seeding or direct database setup.
7. Jobs domain
The job portal core lives in Job model + jobController.js + jobRoutes.js. Anyone can read job listings and job detail pages, but only recruiters can create, edit, or delete jobs, and only for jobs they own. This ownership rule is a key boundary in the backend: authorization is not just role-based, but also resource-scoped.
8. Applications domain
Applications are represented by Application and handled through applicationController.js and applicationRoutes.js. Job seekers submit applications tied to a specific job, then view their own submissions through a dedicated endpoint. Recruiters can inspect applications for jobs they own and update application status, which supports shortlist/reject-style workflow.
9. Admin subsystem
Admin functions are isolated under adminController.js and adminRoutes.js. This area is responsible for platform-level user management, including listing and deleting users. The controller includes a safety guard preventing admins from deleting their own account through the delete-user endpoint.
10. Chat and AI boundary
The repo includes both chatRoutes.js/ChatMessage and an AI utility layer (utils/aiService.js) plus a separate ai-service/ Python package. That suggests AI features such as chat or ATS checking are intentionally separated from the main CRUD API. The React pages Chat.jsx and ATSChecker.jsx sit on top of this boundary, likely calling either the Express AI routes or the standalone Python service depending on deployment.
11. Data persistence
MongoDB is the primary data store, accessed through Mongoose models for User, Job, Application, and ChatMessage. The database is the shared state boundary for the whole platform, while controllers and middleware keep business rules in the API layer rather than in the client.
12. Operational concerns
The backend includes middleware for logging, rate limiting, and centralized error handling, plus a Swagger config for API documentation. There is also a seed.js script for loading demo data, and the root docker-compose.yml indicates the repo is designed for local containerized setup. Environment files in both client and server define runtime boundaries such as MONGODB_URI, JWT_SECRET, CLIENT_URL, and optional API base URL settings.
13. Typical request flows
The main user flow is: browser loads the React app → user logs in/registers → token is stored → Axios sends authenticated API requests → Express validates JWT and role → Mongoose reads/writes MongoDB → UI updates based on the response. Separate flows exist for recruiters managing jobs/applications, admins managing users, and AI/chat screens calling the AI-related service boundary.
Main entry points: server.js API Server · User.js Mongo Models · main.jsx Route Shell · Home.jsx Feature Pages
Components 18
Client
React/Vite single-page app and UI state
- Browser UI · User-facing React app for navigation, forms, and role-based views
client/src/App.jsx - Route Shell · Top-level routing and page composition
client/src/main.jsx - Auth State · JWT-backed session and user snapshot stored in client state
client/src/context/AuthContext.jsx - Theme State · Light/dark theme selection and UI preference state
client/src/context/ThemeContext.jsx - API Client · Authenticated HTTP client and API base URL handling
client/src/api/axios.js - Access Guard · Role-based protected route wrapper for dashboard and admin views
client/src/components/ProtectedRoute.jsx - Feature Pages · Home, auth, dashboards, jobs, applications, chat, and ATS checking screens
client/src/pages/Home.jsx
Server
Express API, persistence, and domain logic
- API Server · Backend bootstrap and middleware wiring
server/server.js - Auth API · Registration, login, token issuance, and current-user flows
server/controllers/authController.js - Jobs API · Job listing and recruiter-owned CRUD operations
server/controllers/jobController.js - Applications API · Apply, inspect submissions, and update application status
server/controllers/applicationController.js - Admin API · Platform user management and protected admin actions
server/controllers/adminController.js - Chat API · Chat and AI-facing HTTP endpoints
server/routes/chatRoutes.js - Mongo Models · User, Job, Application, and ChatMessage persistence models
server/models/User.js - Middleware Layer · JWT protection, role checks, logging, rate limiting, and error handling
server/middleware/auth.js - MongoDB · Primary persistent data store for the platform
server/config/db.js - Server Utils · Token generation, email helpers, and AI integration support
server/utils/generateToken.js
AI Service
Standalone Python service for AI features
- Python AI · Separate Python service for AI-related processing
ai-service/main.py
Connections 22
- Browser UI → Route Shell: renders · The React app is composed through the route shell
- Route Shell → Feature Pages: navigates · Routes switch between page-level feature screens
- Route Shell → Access Guard: protects · Protected routes gate sensitive dashboards and admin screens
- Access Guard → Auth State: reads session · Route access depends on user identity and role
- Feature Pages → API Client: requests · Pages fetch and mutate data through the shared API client
- API Client → API Server: HTTP /api · Authenticated REST calls go to the Express backend
- Auth State → API Client: attaches token · Stored JWT is reused for authorized requests
- Theme State → Browser UI: themes UI · Theme context affects client presentation
- API Server → Middleware Layer: applies · Requests pass through middleware for security and observability
- API Server → Auth API: routes auth · Authentication endpoints are mounted on the server
- API Server → Jobs API: routes jobs · Job endpoints are mounted on the server
- API Server → Applications API: routes applications · Application endpoints are mounted on the server
- API Server → Admin API: routes admin · Admin endpoints are mounted on the server
- API Server → Chat API: routes chat · Chat and AI-related endpoints are mounted on the server
- Auth API → Server Utils: issues token · Auth logic relies on token generation utilities
- Jobs API → Mongo Models: reads/writes · Job controller persists through Mongoose models
- Applications API → Mongo Models: reads/writes · Applications are stored and queried via models
- Admin API → Mongo Models: reads/writes · Admin user management operates on persisted users
- Chat API → Server Utils: uses AI · Chat endpoints can invoke AI helper utilities
- Mongo Models → MongoDB: persists to · All major domain models map to MongoDB
- Chat API → Python AI: delegates · AI-specific requests can be handled by the separate Python service
- Feature Pages → Python AI: AI screens · Chat and ATS checking screens sit on the AI feature boundary