How muhammedshaduli/campuscrm works
Purpose and Entry Points
This is a CRM-style application with a Node.js backend API and a static browser frontend. The backend starts at backend/src/server.js, builds the Express application in backend/src/app.js, and mounts feature routes through backend/src/routes/index.js. The frontend is served or opened from frontend/index.html, with client behavior in frontend/script.js.
API Composition Layer
The Express app centralizes HTTP concerns before delegating to domain modules. backend/src/app.js configures application-level behavior; backend/src/routes/index.js aggregates module routers; backend/src/server.js owns process startup. Feature route files form the API boundary and direct requests to controllers, e.g. backend/src/modules/leads/leadRoutes.js, backend/src/modules/auth/authRoutes.js, and backend/src/modules/reports/reportRoutes.js.
Identity, Authorization, and Request Protection
Authentication and role-based access control are cross-cutting middleware boundaries. backend/src/middlewares/auth.js establishes authenticated request identity, while backend/src/middlewares/rbac.js gates privileged operations. Authentication endpoints and account workflows reside in backend/src/modules/auth/authController.js, backend/src/modules/users/userController.js, and their associated route modules.
Core CRM Domain Modules
Lead management is a central operational domain, implemented by backend/src/modules/leads/leadController.js and backend/src/modules/leads/leadRoutes.js. Follow-up tracking extends lead/customer activity handling through backend/src/modules/followups/followupController.js. Reference or master-data administration is isolated in backend/src/modules/masters/masterController.js, keeping shared lookup entities separate from transactional workflows.
Finance, Dashboard, and Reporting Read Models
Financial operations are exposed through backend/src/modules/finance/financeController.js and backend/src/modules/finance/financeRoutes.js. Dashboard endpoints in backend/src/modules/dashboard/dashboardController.js likely aggregate operational summaries for the frontend. Report endpoints in backend/src/modules/reports/reportController.js provide a separate reporting/query boundary rather than embedding report logic in lead or finance routes.
Persistence and Infrastructure
Prisma defines the persistence model in backend/prisma/schema.prisma; database connectivity is configured by backend/src/config/db.js, with initial data support in backend/prisma/seed.js. The backend is containerized via backend/Dockerfile and backend/docker-compose.yml. Environment-specific secrets and connection settings are expected through backend/.env.example.
Primary Flow and Error Boundary
A typical request flows from frontend JavaScript (frontend/script.js) to an Express route, through authentication/RBAC middleware where required, into a module controller, then through the database layer defined by Prisma. Controllers return standardized API payloads using backend/src/utils/response.js. Failures are centralized through backend/src/middlewares/error.js, separating operational errors from feature-controller logic.
Main entry points: schema.prisma Prisma data model · rbac.js Role authorization · auth.js Authentication · app.js Express app
Components 18
Browser Client
- Static UI
frontend/index.html - Client behavior
frontend/script.js
Express API
- Server startup
backend/src/server.js - Express app
backend/src/app.js - Route registry
backend/src/routes/index.js - Authentication · Establishes request identity.
backend/src/middlewares/auth.js - Role authorization · Gates privileged operations.
backend/src/middlewares/rbac.js - Error handler · Centralizes API failures.
backend/src/middlewares/error.js - API responses · Standardizes controller payloads.
backend/src/utils/response.js
CRM Modules
- Auth and users
backend/src/modules/auth/authController.js - Lead management
backend/src/modules/leads/leadController.js - Follow-up tracking
backend/src/modules/followups/followupController.js - Master data
backend/src/modules/masters/masterController.js - Finance operations
backend/src/modules/finance/financeController.js - Dashboard summaries · Aggregates operational summaries.
backend/src/modules/dashboard/dashboardController.js - Reporting queries
backend/src/modules/reports/reportController.js
Persistence
- Prisma data model
backend/prisma/schema.prisma - Database connection
backend/src/config/db.js
Connections 25
- Static UI → Client behavior: loads
- Client behavior → Server startup: API requests
- Server startup → Express app: starts
- Express app → Route registry: mounts
- Express app → Error handler: handles failures
- Route registry → Authentication: protected requests
- Authentication → Role authorization: authorized operations
- Route registry → Auth and users: auth routes
- Role authorization → Lead management: lead operations
- Role authorization → Follow-up tracking: activity operations
- Role authorization → Master data: admin operations
- Role authorization → Finance operations: finance operations
- Authentication → Dashboard summaries: dashboard access
- Authentication → Reporting queries: report access
- Auth and users → Prisma data model: reads and writes
- Lead management → Prisma data model: reads and writes
- Follow-up tracking → Prisma data model: reads and writes
- Master data → Prisma data model: reads and writes
- Finance operations → Prisma data model: reads and writes
- Dashboard summaries → Prisma data model: aggregates
- Reporting queries → Prisma data model: queries
- Auth and users → API responses: formats
- Lead management → API responses: formats
- Finance operations → API responses: formats
- Database connection → Prisma data model: connects