How abhadimishra/erp works
Purpose and Top-Level Shape
This is a full-stack ERP-style application with a React/Vite client and a separate backend organized around authentication, user/admin/staff, and student operations. The README is only the Vite template; repository structure is the primary architectural evidence.
Runtime Entry Points
• Frontend bootstraps from src/main.jsx, composes the application in src/App.jsx, and is served/built through vite.config.js.
• Backend starts from backend_ERP/server.js; database setup is isolated in backend_ERP/config/db.js.
• Environment-dependent values are expected through .env, likely covering database, server, auth, and/or email settings.
Frontend Application Shell and Views
The frontend is a React single-page application. Core user-facing areas include authentication, dashboard/navigation, student management, and staff/user data:
• src/components/frontend/Login.jsx
• src/components/frontend/Dashboard.jsx
• src/components/frontend/Student_Page.jsx
• src/components/frontend/StaffData.jsx
• src/components/frontend/SideBar.jsx
Shared UI patterns for tables and update/delete actions are represented by src/components/frontend/DataTable.jsx and src/components/frontend/Delete_Update.jsx.
Client State, Routing Protection, and API Boundary
Authentication state is centralized in Redux:
• src/components/reduxStore/store.js
• src/components/reduxStore/authSlice.js
Route access is guarded by src/components/ProtectedRoutes/ProtectedRoute.jsx, forming the client-side authorization boundary. HTTP concerns are consolidated rather than embedded directly in page components:
• src/api_gateway/axiosInstance.js
• src/api_gateway/interceptors.js
• src/api_gateway/api.js
This layer likely attaches credentials, handles common response failures, and presents a consistent API interface to views.
Backend HTTP and Authorization Pipeline
Backend routing is grouped by domain and composed through:
• backend_ERP/routes/index.js
• backend_ERP/routes/auth.routes.js
• backend_ERP/routes/admin.routes.js
• backend_ERP/routes/student.routes.js
• backend_ERP/routes/user.routes.js
Requests pass through authentication and role/permission enforcement middleware before protected controller actions:
• backend_ERP/middlewares/auth.js
• backend_ERP/middlewares/authorize.js
Controllers provide the HTTP-facing boundary for their domains, including backend_ERP/controllers/auth.controller.js, backend_ERP/controllers/admin.controller.js, and backend_ERP/controllers/student.controller.js.
Domain Services and Persistence
Business operations are separated into services, keeping controllers focused on request/response handling:
• backend_ERP/services/admin.service.js
• backend_ERP/services/student.service.js
• backend_ERP/services/user.service.js
Persistent entities cover users, employees/staff, students, and OTP records:
• backend_ERP/models/user.model.js
• backend_ERP/models/employee.model.js
• backend_ERP/models/student.model.js
• backend_ERP/models/otp.model.js
The database connection boundary is backend_ERP/config/db.js; the specific database vendor is not established by the provided tree.
Authentication and Recovery Flow
Authentication is a cross-cutting flow spanning frontend login/recovery screens, Redux state, API interception, backend auth routes/controllers, and auth middleware. Password-recovery/OTP support is explicitly represented by:
• src/components/frontend/ForgotPass.jsx
• backend_ERP/controllers/otp.js
• backend_ERP/routes/opt.routes.js
• backend_ERP/services/forgotpassword.js
Backend error propagation is standardized through backend_ERP/utils/AppError.js and backend_ERP/utils/asyncHandler.js, while the client has a UI failure boundary at src/components/errorBoundary/GenericFallback.jsx.
Main entry points: App.jsx Application shell · Dashboard.jsx ERP views · api.js API gateway · index.js Domain routes
Components 18
React Client
- Vite runtime · Serves and builds the client.
vite.config.js - Client entry
src/main.jsx - Application shell
src/App.jsx - ERP views · Login, dashboard, student, and staff screens.
src/components/frontend/Dashboard.jsx - Shared data UI · Reusable tables and update/delete controls.
src/components/frontend/DataTable.jsx - Auth state
src/components/reduxStore/store.js - Protected routes
src/components/ProtectedRoutes/ProtectedRoute.jsx - API gateway · Central API calls, credentials, and response interception.
src/api_gateway/api.js - UI error fallback
src/components/errorBoundary/GenericFallback.jsx
ERP Backend
- Backend server
backend_ERP/server.js - Domain routes · Auth, admin, student, and user endpoints.
backend_ERP/routes/index.js - Auth and authorization · Authenticates requests and enforces roles.
backend_ERP/middlewares/auth.js - HTTP controllers · Auth, admin, and student request handlers.
backend_ERP/controllers/auth.controller.js - Domain services · Admin, student, and user business operations.
backend_ERP/services/admin.service.js - Password recovery · OTP and forgot-password handling.
backend_ERP/controllers/otp.js - Backend error handling · Standardized async and application errors.
backend_ERP/utils/AppError.js
Persistence
- ERP entities · Users, employees, students, and OTP records.
backend_ERP/models/user.model.js - Database connection · Vendor is unspecified.
backend_ERP/config/db.js
Connections 20
- Vite runtime → Client entry: serves/builds
- Client entry → Application shell: mounts
- Application shell → ERP views: renders
- Application shell → Protected routes: guards navigation
- ERP views → Shared data UI: uses
- ERP views → API gateway: requests data
- ERP views → Auth state: reads auth
- Protected routes → Auth state: checks session
- API gateway → Auth state: updates auth failures
- Application shell → UI error fallback: handles UI failures
- API gateway → Backend server: HTTP API
- Backend server → Domain routes: mounts
- Domain routes → Auth and authorization: protects endpoints
- Auth and authorization → HTTP controllers: permits requests
- Domain routes → Password recovery: recovery endpoints
- HTTP controllers → Domain services: delegates
- Password recovery → ERP entities: stores OTPs
- Domain services → ERP entities: reads/writes
- ERP entities → Database connection: persists through
- HTTP controllers → Backend error handling: propagates errors