# adityaupasani594/ecotimeshackathon architecture

> Architecture diagram of the GitHub repository adityaupasani594/ecotimeshackathon, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/adityaupasani594/ecotimeshackathon
- Repository: https://github.com/adityaupasani594/ecotimeshackathon

## Overview

#### Purpose and Runtime Entry Points

CRITPATH is a data-centre EPC scheduling and risk-intelligence platform. It turns schedule, procurement, and specification inputs into a task/equipment knowledge graph, calculates CPM status, and exposes simulation, compliance, and AI-assisted recovery workflows.

Primary runtime entry point: `backend.api:app` in `backend/api.py`, served with Uvicorn. The production UI is built from `frontend/` and served as backend static assets; development UI starts from `frontend/src/main.jsx`.

#### API and Application Boundary

FastAPI is the service boundary for ingestion, graph/CPM retrieval, delay and procurement simulations, mitigation advice, compliance reporting, and grounded chat. `backend/api.py` owns route orchestration and frontend delivery; `backend/database.py` and `backend/data/critpath.db` provide persisted application state where applicable.

The frontend is a React/Vite dashboard. `frontend/src/App.jsx` coordinates API-backed application state and composes the operational views.

#### Ingestion and Canonical Models

The ingestion pipeline normalizes fragmented schedule, procurement, and specification sources into domain objects. `backend/ingestion/parser.py` is the orchestration boundary, delegating structured-file normalization and document extraction to readers such as `backend/ingestion/excel_reader.py` and `backend/ingestion/text_reader.py`. AI-assisted extraction is isolated in `backend/ingestion/llm_extractor.py`.

Canonical scheduling and asset schemas live in `backend/models/task.py` and `backend/models/equipment.py`. Seed inputs are `backend/data/tasks.csv`, `backend/data/procurement.csv`, and `backend/data/specifications.txt`.

#### Dual-Layer Graph Assembly

Graph construction separates logical schedule dependencies from physical asset relationships. `backend/graph/task_graph.py` manages the dependency DAG used for CPM. `backend/graph/equipment_graph.py` represents equipment, tags, specifications, and vendors. `backend/graph/graph_builder.py` assembles both layers, validates them, and creates task-to-equipment cross-links.

This is the core integration boundary: procurement or equipment risks are translated through cross-links into affected installation and commissioning tasks.

#### CPM and Risk Propagation

The CPM engine operates over the validated task DAG. `backend/cpm/forward_pass.py` computes early dates; `backend/cpm/backward_pass.py` computes late dates and float; `backend/cpm/critical_path.py` identifies critical work and propagates injected delays through successors.

Simulation requests enter through the API, modify or evaluate schedule conditions, then return updated finish impact, critical-path status, and downstream effects. Procurement delay simulation first resolves equipment dependencies through the graph layer.

#### Intelligence, Compliance, and External Services

Gemini is the external AI dependency, configured through `GOOGLE_API_KEY`. It is used for ingestion extraction and for recovery/mitigation recommendations, with relevant implementation expected behind `backend/ingestion/llm_extractor.py` and API workflows in `backend/api.py`.

Compliance combines procurement/submittal data with specification text and task sequencing. It detects equipment requirement mismatches and out-of-sequence commissioning risks before presenting them to the UI.

#### Presentation Workflows

`frontend/src/components/GanttChart.jsx` renders CPM timing, dependency links, critical work, and float. `frontend/src/components/Simulator.jsx` drives delay scenarios and AI recovery advice. `frontend/src/components/ComplianceLog.jsx` displays compliance findings, while `frontend/src/components/Copilot.jsx` provides grounded specification Q&A with citations.

The UI consumes backend results rather than owning scheduling logic; graph construction, CPM calculations, persistence, AI calls, and compliance evaluation remain backend responsibilities.

Main entry points: [`backend/api.py`](https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/api.py) (FastAPI service), [`frontend/src/App.jsx`](https://github.com/adityaupasani594/ecotimeshackathon/blob/main/frontend/src/App.jsx) (Dashboard shell), [`backend/ingestion/parser.py`](https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/ingestion/parser.py) (Ingestion parser), [`backend/graph/graph_builder.py`](https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/graph/graph_builder.py) (Graph builder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["React dashboard"]
  node_frontend_app["Dashboard shell<br/>React application<br/>[App.jsx]"]
  node_gantt["Gantt view<br/>CPM visualization<br/>[GanttChart.jsx]"]
  node_simulator["Simulator<br/>scenario workflow<br/>[Simulator.jsx]"]
  node_compliance_log["Compliance log<br/>findings view<br/>[ComplianceLog.jsx]"]
  node_copilot["Copilot<br/>grounded Q&amp;A view<br/>[Copilot.jsx]"]
end

subgraph group_service["Backend service"]
  node_api{{"FastAPI service<br/>API and static host<br/>[api.py]"}}
  node_database[("Application state<br/>SQLite database<br/>[critpath.db]")]
end

subgraph group_ingestion["Ingestion and models"]
  node_parser["Ingestion parser<br/>orchestrator<br/>[parser.py]"]
  node_source_inputs["Seed inputs<br/>schedule and procurement sources<br/>[tasks.csv]"]
  node_readers["Source readers<br/>file and text extraction<br/>[excel_reader.py]"]
  node_llm_extractor["AI extractor<br/>Gemini-assisted extraction<br/>[llm_extractor.py]"]
  node_models["Canonical models<br/>task and equipment schemas<br/>[task.py]"]
end

subgraph group_graph["Graph and scheduling"]
  node_graph_builder{{"Graph builder<br/>integration boundary<br/>[graph_builder.py]"}}
  node_task_graph["Task dependency DAG<br/>schedule graph<br/>[task_graph.py]"]
  node_equipment_graph["Equipment graph<br/>asset relationship graph<br/>[equipment_graph.py]"]
  node_cpm_forward["Forward pass<br/>CPM calculation<br/>[forward_pass.py]"]
  node_cpm_backward["Backward pass<br/>CPM calculation<br/>[backward_pass.py]"]
  node_critical_path["Critical path engine<br/>risk propagation<br/>[critical_path.py]"]
end

node_gemini(("Gemini<br/>external AI service"))

node_frontend_app -->|"composes"| node_gantt
node_frontend_app -->|"composes"| node_simulator
node_frontend_app -->|"composes"| node_compliance_log
node_frontend_app -->|"composes"| node_copilot
node_frontend_app -->|"API requests"| node_api
node_api -->|"persists state"| node_database
node_api -->|"ingestion"| node_parser
node_api -->|"graph and simulation workflows"| node_graph_builder
node_api -->|"recovery advice and chat"| node_gemini
node_source_inputs -->|"schedule and procurement"| node_parser
node_readers -->|"normalized extraction"| node_parser
node_parser -->|"AI-assisted documents"| node_llm_extractor
node_llm_extractor -->|"extracts with"| node_gemini
node_parser -->|"creates"| node_models
node_models -->|"domain objects"| node_graph_builder
node_graph_builder -->|"builds"| node_task_graph
node_graph_builder -->|"builds and cross-links"| node_equipment_graph
node_task_graph -->|"validated DAG"| node_cpm_forward
node_cpm_forward -->|"early dates"| node_cpm_backward
node_cpm_backward -->|"late dates and float"| node_critical_path
node_equipment_graph -->|"equipment delay impacts"| node_critical_path
node_critical_path -->|"CPM and downstream effects"| node_api
node_api -->|"timing and critical work"| node_gantt
node_api -->|"scenario results"| node_simulator
node_api -->|"compliance findings"| node_compliance_log
node_api -->|"grounded answers"| node_copilot

click node_frontend_app "https://github.com/adityaupasani594/ecotimeshackathon/blob/main/frontend/src/App.jsx"
click node_gantt "https://github.com/adityaupasani594/ecotimeshackathon/blob/main/frontend/src/components/GanttChart.jsx"
click node_simulator "https://github.com/adityaupasani594/ecotimeshackathon/blob/main/frontend/src/components/Simulator.jsx"
click node_compliance_log "https://github.com/adityaupasani594/ecotimeshackathon/blob/main/frontend/src/components/ComplianceLog.jsx"
click node_copilot "https://github.com/adityaupasani594/ecotimeshackathon/blob/main/frontend/src/components/Copilot.jsx"
click node_api "https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/api.py"
click node_database "https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/data/critpath.db"
click node_parser "https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/ingestion/parser.py"
click node_source_inputs "https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/data/tasks.csv"
click node_readers "https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/ingestion/excel_reader.py"
click node_llm_extractor "https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/ingestion/llm_extractor.py"
click node_models "https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/models/task.py"
click node_graph_builder "https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/graph/graph_builder.py"
click node_task_graph "https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/graph/task_graph.py"
click node_equipment_graph "https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/graph/equipment_graph.py"
click node_cpm_forward "https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/cpm/forward_pass.py"
click node_cpm_backward "https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/cpm/backward_pass.py"
click node_critical_path "https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/cpm/critical_path.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_frontend_app,node_gantt,node_simulator,node_compliance_log,node_copilot toneBlue
class node_api,node_database toneAmber
class node_parser,node_source_inputs,node_readers,node_llm_extractor,node_models toneMint
class node_graph_builder,node_task_graph,node_equipment_graph,node_cpm_forward,node_cpm_backward,node_critical_path toneRose
class node_gemini toneNeutral
```

## Components

### React dashboard

- [Dashboard shell](https://github.com/adityaupasani594/ecotimeshackathon/blob/main/frontend/src/App.jsx): React application · Coordinates API-backed operational views. · `frontend/src/App.jsx`
- [Gantt view](https://github.com/adityaupasani594/ecotimeshackathon/blob/main/frontend/src/components/GanttChart.jsx): CPM visualization · `frontend/src/components/GanttChart.jsx`
- [Simulator](https://github.com/adityaupasani594/ecotimeshackathon/blob/main/frontend/src/components/Simulator.jsx): scenario workflow · Runs delay scenarios and recovery advice. · `frontend/src/components/Simulator.jsx`
- [Compliance log](https://github.com/adityaupasani594/ecotimeshackathon/blob/main/frontend/src/components/ComplianceLog.jsx): findings view · `frontend/src/components/ComplianceLog.jsx`
- [Copilot](https://github.com/adityaupasani594/ecotimeshackathon/blob/main/frontend/src/components/Copilot.jsx): grounded Q&A view · `frontend/src/components/Copilot.jsx`

### Backend service

- [FastAPI service](https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/api.py): API and static host · Runtime entry point and workflow orchestrator. · `backend/api.py`
- [Application state](https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/data/critpath.db): SQLite database · `backend/data/critpath.db`

### Ingestion and models

- [Ingestion parser](https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/ingestion/parser.py): orchestrator · Normalizes schedule, procurement, and specification sources. · `backend/ingestion/parser.py`
- [Seed inputs](https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/data/tasks.csv): schedule and procurement sources · `backend/data/tasks.csv`
- [Source readers](https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/ingestion/excel_reader.py): file and text extraction · `backend/ingestion/excel_reader.py`
- [AI extractor](https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/ingestion/llm_extractor.py): Gemini-assisted extraction · `backend/ingestion/llm_extractor.py`
- [Canonical models](https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/models/task.py): task and equipment schemas · `backend/models/task.py`

### Graph and scheduling

- [Graph builder](https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/graph/graph_builder.py): integration boundary · Validates both graph layers and creates task-equipment links. · `backend/graph/graph_builder.py`
- [Task dependency DAG](https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/graph/task_graph.py): schedule graph · Logical dependencies used by CPM. · `backend/graph/task_graph.py`
- [Equipment graph](https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/graph/equipment_graph.py): asset relationship graph · Equipment, tags, specifications, and vendors. · `backend/graph/equipment_graph.py`
- [Forward pass](https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/cpm/forward_pass.py): CPM calculation · Computes early dates. · `backend/cpm/forward_pass.py`
- [Backward pass](https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/cpm/backward_pass.py): CPM calculation · Computes late dates and float. · `backend/cpm/backward_pass.py`
- [Critical path engine](https://github.com/adityaupasani594/ecotimeshackathon/blob/main/backend/cpm/critical_path.py): risk propagation · Identifies critical work and propagates delays. · `backend/cpm/critical_path.py`

### Other components

- **Gemini**: external AI service · Used with GOOGLE_API_KEY.

## Connections

- Dashboard shell → Gantt view: composes
- Dashboard shell → Simulator: composes
- Dashboard shell → Compliance log: composes
- Dashboard shell → Copilot: composes
- Dashboard shell → FastAPI service: API requests
- FastAPI service → Application state: persists state
- FastAPI service → Ingestion parser: ingestion
- FastAPI service → Graph builder: graph and simulation workflows
- FastAPI service → Gemini: recovery advice and chat
- Seed inputs → Ingestion parser: schedule and procurement
- Source readers → Ingestion parser: normalized extraction
- Ingestion parser → AI extractor: AI-assisted documents
- AI extractor → Gemini: extracts with
- Ingestion parser → Canonical models: creates
- Canonical models → Graph builder: domain objects
- Graph builder → Task dependency DAG: builds
- Graph builder → Equipment graph: builds and cross-links
- Task dependency DAG → Forward pass: validated DAG
- Forward pass → Backward pass: early dates
- Backward pass → Critical path engine: late dates and float
- Equipment graph → Critical path engine: equipment delay impacts · Cross-links resolve affected installation and commissioning tasks.
- Critical path engine → FastAPI service: CPM and downstream effects
- FastAPI service → Gantt view: timing and critical work
- FastAPI service → Simulator: scenario results
- FastAPI service → Compliance log: compliance findings
- FastAPI service → Copilot: grounded answers
