How aaryankacha/helpdesk-system works
Purpose and Topology
This is a monorepo foundation for a multi-tenant helpdesk platform. It currently provides user authentication, organization membership-aware access, and a protected organization API; ticketing is intentionally future work. The React client and Express API run independently against a shared PostgreSQL database.
• Root orchestration: package.json, docker-compose.yml
• Frontend application: client/src/main.jsx, client/src/App.jsx
• Backend process: server/src/server.js, server/src/app.js
Client Application
The browser client is a Vite React SPA styled with Tailwind. App.jsx is the application composition and route boundary, with separate login, registration, and dashboard screens. The dashboard is the authenticated product surface.
• Bootstrap and root rendering: client/src/main.jsx, client/src/App.jsx
• Auth-facing pages: client/src/pages/LoginPage.jsx, client/src/pages/RegisterPage.jsx
• Authenticated UI: client/src/pages/DashboardPage.jsx
Client Auth and API Boundary
AuthContext owns client-side authentication state and exposes it to pages/components. The API service centralizes requests to the backend using the configurable VITE_API_URL; it is the browser-to-server trust boundary where JWT-bearing requests are assembled.
• Auth state provider: client/src/context/AuthContext.jsx
• HTTP client/service layer: client/src/services/api.js
• Frontend environment contract: client/.env.example
Express API Composition
The server process builds an Express application with security and cross-origin concerns configured around API routes. Route aggregation establishes the /api surface, then domain route modules map HTTP endpoints to controllers. Central middleware handles authentication, request validation, and error translation.
• Application and listener: server/src/app.js, server/src/server.js
• Route root and modules: server/src/routes/index.js, server/src/routes/authRoutes.js, server/src/routes/organizationRoutes.js
• Cross-cutting middleware: server/src/middleware/authMiddleware.js, server/src/middleware/errorMiddleware.js, server/src/middleware/validateMiddleware.js
Authentication Flow
Registration and login requests enter auth routes, are checked against Zod-oriented validation definitions, then reach the auth controller/service layer. The service persists or verifies users through Prisma and issues JWTs. Protected requests, including /api/auth/me, pass through JWT middleware before controllers receive the authenticated principal.
• HTTP orchestration: server/src/controllers/authController.js, server/src/routes/authRoutes.js
• Credential/JWT domain logic: server/src/services/authService.js
• Validation and token enforcement: server/src/validation/authValidation.js, server/src/middleware/authMiddleware.js
Multi-Tenant Organization Access
Organizations are the current tenant boundary. Organization controllers delegate retrieval to a service, with protected routing ensuring callers are authenticated; membership and role-aware behavior are modeled in the database schema rather than in the UI alone. This is the natural attachment point for future tickets, permissions, and tenant-scoped dashboards.
• Organization API layer: server/src/routes/organizationRoutes.js, server/src/controllers/organizationController.js
• Tenant retrieval logic: server/src/services/organizationService.js
• Persistence model: server/prisma/schema.prisma
Persistence and Runtime Infrastructure
PostgreSQL is the sole durable store, accessed by the Node server through Prisma. Docker Compose provides local PostgreSQL, while Prisma schema and seed scripts define and initialize the development data model. Runtime configuration supplies database connectivity, JWT signing, API port, and permitted client origin.
• Database container: docker-compose.yml
• Prisma schema and development fixtures: server/prisma/schema.prisma, server/prisma/seed.js
• Server configuration boundary: server/src/config/index.js, server/.env.example
Main entry points: App.jsx App route boundary · AuthContext.jsx Auth state · app.js Express application · schema.prisma Prisma tenant model
Components 18
React Client
- SPA bootstrap
client/src/main.jsx - App route boundary · Composes login, registration, and dashboard surfaces.
client/src/App.jsx - Auth pages
client/src/pages/LoginPage.jsx - Dashboard
client/src/pages/DashboardPage.jsx - Auth state · Owns client authentication state.
client/src/context/AuthContext.jsx - API service · Builds JWT-bearing requests using the configured API URL.
client/src/services/api.js
Express API
- API process
server/src/server.js - Express application · Configures security, CORS, and API handling.
server/src/app.js - /api routes
server/src/routes/index.js - Auth API · Handles registration, login, and current-user requests.
server/src/routes/authRoutes.js - Organization API · Exposes tenant-scoped organization retrieval.
server/src/routes/organizationRoutes.js - Request guards · Authenticates JWTs, validates input, and translates failures.
server/src/middleware/authMiddleware.js - Auth service
server/src/services/authService.js - Organization service
server/src/services/organizationService.js - Server runtime config · Supplies database, JWT, port, and allowed-origin settings.
server/src/config/index.js
Data & Local Runtime
- Prisma tenant model · Defines users, organizations, memberships, and roles.
server/prisma/schema.prisma - PostgreSQL · Local database is supplied through Compose.
docker-compose.yml - Development seed
server/prisma/seed.js
Connections 22
- SPA bootstrap → App route boundary: renders
- App route boundary → Auth pages: routes to
- App route boundary → Dashboard: routes to
- App route boundary → Auth state: provides auth state
- Auth pages → Auth state: signs in or registers
- Dashboard → Auth state: reads session
- Auth state → API service: uses
- API service → Express application: HTTP requests with JWT
- API process → Express application: starts
- Express application → /api routes: mounts
- /api routes → Auth API: auth endpoints
- /api routes → Organization API: organization endpoints
- Auth API → Request guards: validates and authenticates
- Organization API → Request guards: requires JWT
- Auth API → Auth service: delegates
- Organization API → Organization service: delegates
- Auth service → Prisma tenant model: persists and verifies users
- Organization service → Prisma tenant model: queries memberships
- Prisma tenant model → PostgreSQL: maps to
- Development seed → Prisma tenant model: initializes
- Server runtime config → Express application: configures
- Server runtime config → PostgreSQL: database connection