Backend & Frontend Enums, Choices & Schema Reference
Complete, unified dictionary of database text choices (models.TextChoices), TypeScript enums, scheduling weights, status lifecycles, and API serialization aliases.
1. Asset Department (Asset.Department / AssetDepartment)
Backend model: apps.assets.models.Asset.department (API alias: division)
| Database Key | Display Label | Infrastructure Scope & Responsibility |
|---|---|---|
| ENGINEERING | Engineering | Track, rails, sleepers, ballast, civil structures, bridges |
| SNT | Signal & Telecom | Signaling equipment, electronic interlocking, points, telecommunications |
| TRACTION | Traction (TRD) | Overhead Electrification (OHE), power supply, substations, mast poles |
2. Asset Categories (AssetCategory)
Backend field: apps.assets.models.Asset.asset_type (API alias: category)
| Category Choice Key | Display Label | Department | Typical Maintenance Window |
|---|---|---|---|
| TRACK_CIRCUIT | Track Circuit | SNT | 30 - 60 mins |
| SIGNAL | Signal & Interlocking | SNT | 45 - 90 mins |
| POINT_MACHINE | Point Machine / Switch | SNT | 45 - 60 mins |
| OVERHEAD_EQUIPMENT | OHE / Traction Catenary | TRACTION | 60 - 180 mins |
| TRANSFORMER | Substation Transformer | TRACTION | 90 - 240 mins |
| TRACK_SEGMENT | Track Segment / Rail | ENGINEERING | 60 - 180 mins |
| AXLE_COUNTER | Axle Counter | SNT | 30 - 45 mins |
| INTERLOCKING | Electronic Interlocking | SNT | 60 - 120 mins |
3. Maintenance Task Urgency / Priority & Objective Weights
Backend field: apps.maintenance.models.MaintenanceTask.priority (API alias: urgency)
| Choice Key | Display Label | CP-SAT Weight | Operational Severity |
|---|---|---|---|
| CRITICAL | Critical | 40.0 | Severe safety risk or immediate operational hazard; highest allocation priority |
| HIGH | High | 30.0 | Significant wear or disruption risk; requires near-term maintenance block |
| MEDIUM | Medium | 20.0 | Standard routine inspection, preventive repair, or periodic check |
| LOW | Low | 10.0 | Minor maintenance or non-critical cosmetic/support activity |
4. Maintenance Task Status Lifecycle
Backend field: apps.maintenance.models.MaintenanceTask.status (API alias: task_status)
| Status Key | Display Badge | State Description & Automation Hook |
|---|---|---|
| PENDING | Pending | Initial state; task created, awaiting block window reservation |
| SCHEDULED | Scheduled | Block window reserved and linked to the task |
| DELAYED | Delayed (Overdue) | Automatic Overdue: Deadline elapsed without completion (is_overdue=True) |
| COMPLETED | Completed | Maintenance work successfully executed on site |
| CANCELLED | Cancelled | Task dismissed or superseded |
5. Block Window Status (BlockWindow.Status)
Backend field: apps.blocks.models.BlockWindow.status
Section window is open and available for maintenance scheduling.
Corridor block is reserved for an approved maintenance task.
Track is actively blocked; maintenance crew on track.
6. AI Optimization Algorithms (algorithm)
| Algorithm Key | Optimization Mechanism |
|---|---|
| CP-SAT Constraint Solver | Google OR-Tools CP-SAT evaluating task priority, safety buffers, network delay impact, and train headway. |
| Database Timestamp Gap | Deterministic fail-safe finding optimal collision-free intervals between live train movements. |
8. Train Types & Priority Levels (Train.TrainType)
| Code Key | Category Name | Default Priority | Description |
|---|---|---|---|
| VB | Vande Bharat | 10 | Semi-high speed premium train sets |
| SHATABDI | Shatabdi Express | 10 | Superfast day intercity services |
| RAJDHANI | Rajdhani Express | 10 | High-priority long-distance national capital express |
| EXPRESS | Express / Superfast | 8 (6–9) | Mail, Express, and Superfast long-distance passenger services |
| PASSENGER | Passenger / MEMU | 5 | Ordinary passenger and local commuter shuttles |
| FREIGHT | Freight / Goods | 5 | Heavy goods, coal, container, and auto rakes |
9. 7-Day Running Days Bitmask Pattern (TrainSchedule.running_days)
7-character binary regex ^[01]{7}$ representing Monday through Sunday:
10. API Field Mappings & Serialization Aliases
Direct crosswalk between frontend JSON keys and Django ORM database model fields:
| Resource | Frontend API Key | Backend Database Field | Notes & Format |
|---|---|---|---|
| Asset | asset_title | name | Asset descriptive title |
| Asset | category | asset_type | AssetCategory choice |
| Asset | division | department | ENGINEERING / SNT / TRACTION |
| Asset | risk_level | criticality | Integer rating (1–5) |
| Task | task_code | task_id | Unique code (e.g. TMS-746) |
| Task | details | description | Task description text |
| Task | urgency | priority | CRITICAL / HIGH / MEDIUM / LOW |
| Task | deadline | due_date | Due date YYYY-MM-DD |
| Task | task_status | status | PENDING / SCHEDULED / DELAYED / COMPLETED |
| Task | is_delayed | is_overdue | True if past due date |
| Block | start_time | start_time | YYYY-MM-DD HH:MM:SS (IST) |
| Block | end_time | end_time | YYYY-MM-DD HH:MM:SS (IST) |
