How maharabhi01/e-challan works
Purpose and Runtime Shape
This is a full-stack e-challan/traffic-violation system. It supports two roles: drivers view vehicles, violations, and payments; officers register and manage violations. The application is split into a Node.js backend API and a React frontend SPA.
• Backend entry point: final echalllan/Backend/src/server.js
• Frontend entry point and router: final echalllan/frontend/src/main.jsx, final echalllan/frontend/src/routes/App.jsx
Backend API and Routing Boundary
server.js composes the HTTP server and mounts role- and domain-oriented route modules. Routes are the API boundary consumed by the frontend service layer.
• final echalllan/Backend/src/routes/auth.routes.js
• final echalllan/Backend/src/routes/driver.routes.js
• final echalllan/Backend/src/routes/officer.routes.js
• final echalllan/Backend/src/routes/payment.routes.js
• final echalllan/Backend/src/routes/public.routes.js
Identity, Authentication, and Role Access
Authentication is centralized in the auth controller and middleware. The frontend maintains authenticated state and applies route protection before rendering private driver or officer areas.
• Backend: final echalllan/Backend/src/controllers/auth.controller.js, final echalllan/Backend/src/middleware/auth.js
• Frontend: final echalllan/frontend/src/context/auth/AuthContext.jsx, final echalllan/frontend/src/routes/Protected.jsx
• User onboarding screens: final echalllan/frontend/src/pages/RegisterDriver.jsx, final echalllan/frontend/src/pages/RegisterOfficer.jsx
Driver Workflow
Drivers operate through a dedicated layout and pages for vehicle records, issued violations, quick fine payment, and payment history. These flows call the backend driver and payment APIs through the shared API client.
• UI: final echalllan/frontend/src/pages/driver/DriverLayout.jsx, final echalllan/frontend/src/pages/driver/MyViolations.jsx, final echalllan/frontend/src/pages/driver/PayFineQuick.jsx
• API ownership: final echalllan/Backend/src/controllers/driver.controller.js, final echalllan/Backend/src/controllers/payment.controller.js
• Client boundary: final echalllan/frontend/src/services/api.js
Officer Violation Workflow
Officers use a separate protected layout to create violations and manage existing records. The officer controller and routes form the server-side boundary for enforcement operations.
• UI: final echalllan/frontend/src/pages/officer/OfficerLayout.jsx, final echalllan/frontend/src/pages/officer/AddViolation.jsx, final echalllan/frontend/src/pages/officer/ManageViolations.jsx
• API: final echalllan/Backend/src/controllers/officer.controller.js, final echalllan/Backend/src/routes/officer.routes.js
Persistence and Payment Integration
The backend uses a database connection module and SQL schema as its persistence boundary. Payment processing is isolated behind a payment controller and Razorpay configuration; the frontend exposes Razorpay and UPI payment components.
• Database: final echalllan/Backend/src/config/db.js, final echalllan/Backend/src/models/schema.sql
• Razorpay: final echalllan/Backend/src/config/razorpay.config.js, final echalllan/Backend/src/controllers/payment.controller.js
• Payment UI: final echalllan/frontend/src/components/RazorpayPayment.jsx, final echalllan/frontend/src/components/UPIPayment.jsx
Delivery and External Dependencies
The frontend is built as a static SPA, with compiled output under final echalllan/frontend/dist/; it must be served separately or by deployment infrastructure. Runtime configuration is environment-driven for both tiers.
• Backend environment: final echalllan/Backend/.env
• Frontend environment: final echalllan/frontend/.env
• Built frontend artifact: final echalllan/frontend/dist/index.html
Main entry points: server.js HTTP server · api.js API client · db.js Traffic system database · auth.controller.js Authentication & role checks
Components 20
React SPA
- SPA bootstrap & router
final echalllan/frontend/src/main.jsx - Auth state & guards
final echalllan/frontend/src/context/auth/AuthContext.jsx - Driver & officer registration
final echalllan/frontend/src/pages/RegisterDriver.jsx - Driver portal
final echalllan/frontend/src/pages/driver/DriverLayout.jsx - Officer portal
final echalllan/frontend/src/pages/officer/OfficerLayout.jsx - API client
final echalllan/frontend/src/services/api.js - Payment components
final echalllan/frontend/src/components/RazorpayPayment.jsx
Node.js API
- HTTP server
final echalllan/Backend/src/server.js - Auth routes
final echalllan/Backend/src/routes/auth.routes.js - Driver routes
final echalllan/Backend/src/routes/driver.routes.js - Officer routes
final echalllan/Backend/src/routes/officer.routes.js - Payment routes
final echalllan/Backend/src/routes/payment.routes.js - Public routes
final echalllan/Backend/src/routes/public.routes.js - Authentication & role checks
final echalllan/Backend/src/controllers/auth.controller.js - Driver workflow
final echalllan/Backend/src/controllers/driver.controller.js - Violation enforcement
final echalllan/Backend/src/controllers/officer.controller.js - Payment processing
final echalllan/Backend/src/controllers/payment.controller.js
Persistence
- Traffic system database · Stores users, vehicles, violations, and payments.
final echalllan/Backend/src/config/db.js - Database schema
final echalllan/Backend/src/models/schema.sql
Payment Provider
- Razorpay
final echalllan/Backend/src/config/razorpay.config.js
Connections 27
- SPA bootstrap & router → Auth state & guards: provides session
- SPA bootstrap & router → Driver & officer registration: routes
- Auth state & guards → Driver portal: authorizes driver
- Auth state & guards → Officer portal: authorizes officer
- Driver & officer registration → API client: registers via
- Driver portal → API client: uses
- Officer portal → API client: uses
- Driver portal → Payment components: pays fines with
- Payment components → API client: creates payment
- API client → HTTP server: HTTP API
- HTTP server → Auth routes: mounts
- HTTP server → Driver routes: mounts
- HTTP server → Officer routes: mounts
- HTTP server → Payment routes: mounts
- HTTP server → Public routes: mounts
- Auth routes → Authentication & role checks: delegates
- Driver routes → Driver workflow: delegates
- Officer routes → Violation enforcement: delegates
- Payment routes → Payment processing: delegates
- Driver routes → Authentication & role checks: requires access control
- Officer routes → Authentication & role checks: requires access control
- Authentication & role checks → Traffic system database: reads users
- Driver workflow → Traffic system database: reads vehicles & violations
- Violation enforcement → Traffic system database: creates and manages violations
- Payment processing → Traffic system database: records payments
- Payment processing → Razorpay: processes payment
- Database schema → Traffic system database: defines