How zephyrus2822/sih2025 works
Purpose and Entry Points
This is a railway operations platform with role-specific web dashboards, passenger services, predictive maintenance/ML, complaints, chatbot support, and automated engineer job assignment. It consists of a Next.js frontend and Python backend. Main entry points are src/app/page.tsx, src/app/layout.tsx, and src/backend/main.py.
Frontend Application Shell and Localization
The frontend uses the Next.js App Router. Global layout and styling originate at src/app/layout.tsx and src/app/globals.css. Locale-scoped pages use src/app/[locale]/layout.tsx and src/app/[locale]/page.tsx, backed by translation assets in public/locales/en/common.json and public/locales/hi/common.json. Shared i18n setup is in src/components/I18nProvider.tsx and src/lib/i18n.ts.
Role-Oriented Operational Portals
Separate route groups expose tailored interfaces for employees, engineers, locomotive pilots, maintainers, and passengers. Each dashboard generally has a server route page that mounts a client-side interaction component:
• Engineer work management: src/app/engineer_dashboard/page.tsx, src/app/engineer_dashboard/EngineerDashboardClient.tsx
• Employee job view: src/app/employee_dashboard/page.tsx, src/app/employee_dashboard/EmployeeJobsClient.tsx
• Loco-pilot and maintainer views: src/app/locopilot_dashboard/LocoPilotDashboardClient.tsx, src/app/maintainer_dashboard/MaintainerDashboardClient.tsx
• Passenger-facing services: src/app/passenger_dashboard/page.tsx, src/app/passenger_dashboard/complaints/page.tsx, src/app/passenger_dashboard/schedule/page.tsx
Backend API Boundary
The Python service is organized by domain routers registered from src/backend/main.py. Domain APIs isolate authentication, chat, complaints, personnel workflows, contact/footer data, and pilot workflows:
• src/backend/auth/routes.py
• src/backend/chatbot/routes.py
• src/backend/complaints/routes.py
• src/backend/engineer/routes.py
• src/backend/locopilot/routes.py
The frontend’s client components are the primary consumer boundary for these APIs; API implementation, persistence, and business rules remain under src/backend.
Persistence and Validation
Relational database connectivity and ORM-style data models are centralized in src/backend/db/database_connection.py and src/backend/db/database_models.py. The validation domain has its own data-access, models, schemas, routes, and service layer, separating request contracts from validation business logic: src/backend/validation/routes.py, src/backend/validation/service.py, and src/backend/validation/db.py. SQL bootstrap/snapshot assets are provided by backup.sql and backup_clean.sql.
Predictive Model Pipeline
The deep-learning subsystem serves model-driven predictions through src/backend/dl_model/routes.py. It contains request/database schemas, model persistence, data import, training, metrics, and reporting stages:
• Model artifacts/implementation: src/backend/dl_model/model.h5, src/backend/dl_model/model/model.py
• Training and evaluation: src/backend/dl_model/services/training_service.py, src/backend/dl_model/services/metrics.py
• Dataset ingestion/reporting: src/backend/dl_model/scripts/import_csv.py, src/backend/dl_model/services/report_service.py
Its UI is mounted at src/app/predictor/page.tsx and src/app/predictor/PredictorClient.tsx.
Asynchronous Job Distribution
Engineer-job allocation is a distinct asynchronous subsystem. API requests enter through src/backend/job_distributor/api.py; assignment decisions are implemented in src/backend/job_distributor/assigner.py; work is dispatched and executed through Celery configuration/tasks in src/backend/job_distributor/celery_app.py and src/backend/job_distributor/tasks.py. Worker deployment is represented by src/backend/job_distributor/worker_entrypoint.sh. This boundary prevents allocation work from blocking normal API requests.
Runtime, Deployment, and Observability
The frontend runs in the Node/Next.js ecosystem (package.json, next.config.ts). The backend is containerized with src/backend/Dockerfile and Python dependencies in src/backend/requirements.txt; compose definitions exist at docker-compose.yml and src/backend/backend-docker-compose.yml. Monitoring infrastructure uses Prometheus and Grafana assets in observibility/prometheus.yml, observibility/docker-compose.yml, and observibility/grafana_dashboard.json. The frontend includes a Grafana embedding component at src/components/ui/grafanaembed.tsx.
Main entry points: main.py Backend API app · layout.tsx App shell & locales · database_connection.py Relational database · routes.py Prediction API
Components 20
Next.js Frontend
- App shell & locales · Global and locale layouts provide localized application entry.
src/app/layout.tsx - i18n provider · Translation setup serves English and Hindi assets.
src/components/I18nProvider.tsx - Staff portals · Engineer, employee, loco-pilot, and maintainer operational views.
src/app/engineer_dashboard/EngineerDashboardClient.tsx - Passenger services · Passenger dashboard, complaints, and schedule services.
src/app/passenger_dashboard/page.tsx - Predictor UI
src/app/predictor/PredictorClient.tsx - Grafana embed
src/components/ui/grafanaembed.tsx
Python API
- Backend API app · Registers domain routers and serves the frontend boundary.
src/backend/main.py - Domain routers · Auth, chat, complaints, engineer, and loco-pilot endpoints.
src/backend/engineer/routes.py - Validation service · Separates validation contracts, data access, and business logic.
src/backend/validation/service.py - Relational database · Shared connectivity and data models for backend domains.
src/backend/db/database_connection.py
Predictive Maintenance
- Prediction API
src/backend/dl_model/routes.py - Trained model · Deep-learning model used for prediction serving.
src/backend/dl_model/model/model.py - Training & metrics · Trains and evaluates predictive models.
src/backend/dl_model/services/training_service.py - Dataset import & reports · Imports datasets and produces model reports.
src/backend/dl_model/scripts/import_csv.py
Async Job Distribution
- Job allocation API · Accepts engineer allocation requests without blocking APIs.
src/backend/job_distributor/api.py - Assignment engine
src/backend/job_distributor/assigner.py - Celery tasks · Dispatches and executes allocation work.
src/backend/job_distributor/tasks.py - Worker deployment
src/backend/job_distributor/worker_entrypoint.sh
Runtime & Observability
- Container deployment · Runs frontend and backend service environments.
docker-compose.yml - Prometheus & Grafana · Collects and visualizes runtime monitoring data.
observibility/docker-compose.yml
Connections 24
- App shell & locales → i18n provider: provides locale context
- App shell & locales → Staff portals: routes to
- App shell & locales → Passenger services: routes to
- App shell & locales → Predictor UI: routes to
- Staff portals → Backend API app: calls APIs
- Passenger services → Backend API app: calls APIs
- Predictor UI → Prediction API: requests predictions
- Backend API app → Domain routers: registers
- Backend API app → Validation service: routes validation
- Backend API app → Job allocation API: exposes allocation
- Domain routers → Relational database: persists domain data
- Validation service → Relational database: reads and writes
- Prediction API → Trained model: uses
- Prediction API → Relational database: uses schemas and data
- Dataset import & reports → Training & metrics: supplies datasets
- Training & metrics → Trained model: produces artifact
- Training & metrics → Dataset import & reports: reports results
- Job allocation API → Assignment engine: submits allocation
- Assignment engine → Celery tasks: dispatches
- Worker deployment → Celery tasks: executes
- Celery tasks → Relational database: updates assignments
- Container deployment → Backend API app: deploys
- Container deployment → Prometheus & Grafana: runs stack
- Prometheus & Grafana → Grafana embed: visualized in