# ashokknayak1234/outcome-water architecture

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

- Interactive diagram: https://gitdiagram.com/ashokknayak1234/outcome-water
- Repository: https://github.com/ashokknayak1234/outcome-water

## Overview

OutcomeLoop is a local water-outcome case demo: users review evidence, receive staged AI recommendations, record human approval and work, then assess measured changes and evidence sufficiency. The React dashboard calls a FastAPI API; its workflow combines deterministic metrics, validated model responses, and optional candidate ranking. State is in memory and seeded from demo files. The graph reflects shown calls and README-described behavior; unsampled implementation details are not inferred.

Main entry points: [`backend/app/workflow.py`](https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/workflow.py) (Stage orchestrator), [`frontend/src/App.jsx`](https://github.com/ashokknayak1234/outcome-water/blob/main/frontend/src/App.jsx) (Page router), [`backend/app/routes.py`](https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/routes.py) (Case endpoints), [`frontend/src/pages/Dashboard.jsx`](https://github.com/ashokknayak1234/outcome-water/blob/main/frontend/src/pages/Dashboard.jsx) (Case dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["User interface"]
  node_app["Page router<br/>[App.jsx]"]
  node_landing["Landing page<br/>[Landing.jsx]"]
  node_how["Workflow guide<br/>[HowItWorks.jsx]"]
  node_dashboard["Case dashboard<br/>[Dashboard.jsx]"]
  node_api_client["API client<br/>[api.js]"]
end

subgraph group_api["API and case state"]
  node_server["FastAPI server<br/>[main.py]"]
  node_routes["Case endpoints<br/>[routes.py]"]
  node_schemas["Validated records<br/>[schemas.py]"]
  node_store[("In-memory case state<br/>[case_store.py]")]
  node_seed["Demo case data<br/>[case-001.json]"]
end

subgraph group_workflow["Case workflow"]
  node_workflow_engine["Stage orchestrator<br/>[workflow.py]"]
  node_investigation["Investigation<br/>[workflow.py]"]
  node_analysis["Analysis<br/>[workflow.py]"]
  node_resolution["Resolution<br/>[workflow.py]"]
  node_verification["Outcome verification<br/>[workflow.py]"]
  node_metrics["Deterministic metrics<br/>[calculations.py]"]
  node_transition["State transitions<br/>[transitions.py]"]
end

subgraph group_integrations["Model and ranking"]
  node_ollama["Local Ollama"]
  node_ollama_client["Model client<br/>[ollama_client.py]"]
  node_ranker["Candidate ranker<br/>[decision_ranker.py]"]
end

node_user(("Case user"))

node_user -->|"opens"| node_app
node_app -->|"routes to"| node_landing
node_app -->|"routes to"| node_how
node_app -->|"routes to"| node_dashboard
node_user -->|"uses"| node_dashboard
node_dashboard -->|"calls"| node_api_client
node_api_client -.->|"HTTP requests"| node_server
node_server -->|"registers"| node_routes
node_routes -->|"reads and edits"| node_store
node_routes -->|"runs"| node_workflow_engine
node_routes -.->|"changes state"| node_transition
node_store -->|"loads seed"| node_seed
node_workflow_engine -->|"runs stages"| node_investigation
node_workflow_engine -->|"runs stages"| node_analysis
node_workflow_engine -->|"runs stages"| node_resolution
node_workflow_engine -->|"runs stage"| node_verification
node_workflow_engine -->|"calculates metrics"| node_metrics
node_workflow_engine -->|"edits case"| node_store
node_workflow_engine -->|"requests generation"| node_ollama_client
node_ollama_client -->|"generates JSON"| node_ollama
node_workflow_engine -->|"ranks candidates"| node_ranker
node_workflow_engine -->|"validates outputs"| node_schemas

click node_app "https://github.com/ashokknayak1234/outcome-water/blob/main/frontend/src/App.jsx"
click node_landing "https://github.com/ashokknayak1234/outcome-water/blob/main/frontend/src/pages/Landing.jsx"
click node_how "https://github.com/ashokknayak1234/outcome-water/blob/main/frontend/src/pages/HowItWorks.jsx"
click node_dashboard "https://github.com/ashokknayak1234/outcome-water/blob/main/frontend/src/pages/Dashboard.jsx"
click node_api_client "https://github.com/ashokknayak1234/outcome-water/blob/main/frontend/src/lib/api.js"
click node_server "https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/main.py"
click node_routes "https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/routes.py"
click node_schemas "https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/schemas.py"
click node_store "https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/case_store.py"
click node_seed "https://github.com/ashokknayak1234/outcome-water/blob/main/demo-data/case-001.json"
click node_workflow_engine "https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/workflow.py"
click node_investigation "https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/workflow.py"
click node_analysis "https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/workflow.py"
click node_resolution "https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/workflow.py"
click node_verification "https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/workflow.py"
click node_metrics "https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/calculations.py"
click node_transition "https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/transitions.py"
click node_ollama_client "https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/ollama_client.py"
click node_ranker "https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/decision_ranker.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_app,node_landing,node_how,node_dashboard,node_api_client,node_user toneBlue
class node_server,node_routes,node_schemas,node_store,node_seed toneAmber
class node_workflow_engine,node_investigation,node_analysis,node_resolution,node_verification,node_metrics,node_transition toneMint
class node_ollama,node_ollama_client,node_ranker toneRose
```

## Components

### User interface

- [Page router](https://github.com/ashokknayak1234/outcome-water/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Landing page](https://github.com/ashokknayak1234/outcome-water/blob/main/frontend/src/pages/Landing.jsx): `frontend/src/pages/Landing.jsx`
- [Workflow guide](https://github.com/ashokknayak1234/outcome-water/blob/main/frontend/src/pages/HowItWorks.jsx): `frontend/src/pages/HowItWorks.jsx`
- [Case dashboard](https://github.com/ashokknayak1234/outcome-water/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [API client](https://github.com/ashokknayak1234/outcome-water/blob/main/frontend/src/lib/api.js): `frontend/src/lib/api.js`

### API and case state

- [FastAPI server](https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/main.py): `backend/app/main.py`
- [Case endpoints](https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/routes.py): `backend/app/routes.py`
- [Validated records](https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/schemas.py): `backend/app/schemas.py`
- [In-memory case state](https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/case_store.py): `backend/app/case_store.py`
- [Demo case data](https://github.com/ashokknayak1234/outcome-water/blob/main/demo-data/case-001.json): `demo-data/case-001.json`

### Case workflow

- [Stage orchestrator](https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/workflow.py): `backend/app/workflow.py`
- [Investigation](https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/workflow.py): `backend/app/workflow.py`
- [Analysis](https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/workflow.py): `backend/app/workflow.py`
- [Resolution](https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/workflow.py): `backend/app/workflow.py`
- [Outcome verification](https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/workflow.py): `backend/app/workflow.py`
- [Deterministic metrics](https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/calculations.py): `backend/app/calculations.py`
- [State transitions](https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/transitions.py): `backend/app/transitions.py`

### Model and ranking

- **Local Ollama**
- [Model client](https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/ollama_client.py): `backend/app/ollama_client.py`
- [Candidate ranker](https://github.com/ashokknayak1234/outcome-water/blob/main/backend/app/decision_ranker.py): `backend/app/decision_ranker.py`

### Other components

- **Case user**

## Connections

- Case user → Page router: opens (evidence: `frontend/src/App.jsx`)
- Page router → Landing page: routes to (evidence: `frontend/src/App.jsx`)
- Page router → Workflow guide: routes to (evidence: `frontend/src/App.jsx`)
- Page router → Case dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Case user → Case dashboard: uses (evidence: `frontend/src/pages/Dashboard.jsx`)
- Case dashboard → API client: calls (evidence: `frontend/src/pages/Dashboard.jsx`)
- API client → FastAPI server: HTTP requests
- FastAPI server → Case endpoints: registers (evidence: `backend/app/main.py`)
- Case endpoints → In-memory case state: reads and edits (evidence: `backend/app/routes.py`)
- Case endpoints → Stage orchestrator: runs (evidence: `backend/app/routes.py`)
- Case endpoints → State transitions: changes state (evidence: `backend/app/routes.py`)
- In-memory case state → Demo case data: loads seed (evidence: `backend/app/case_store.py`)
- Stage orchestrator → Investigation: runs stages (evidence: `backend/app/workflow.py`)
- Stage orchestrator → Analysis: runs stages (evidence: `backend/app/workflow.py`)
- Stage orchestrator → Resolution: runs stages (evidence: `backend/app/workflow.py`)
- Stage orchestrator → Outcome verification: runs stage (evidence: `backend/app/workflow.py`)
- Stage orchestrator → Deterministic metrics: calculates metrics (evidence: `backend/app/workflow.py`)
- Stage orchestrator → In-memory case state: edits case (evidence: `backend/app/workflow.py`)
- Stage orchestrator → Model client: requests generation (evidence: `backend/app/workflow.py`)
- Model client → Local Ollama: generates JSON (evidence: `backend/app/ollama_client.py`)
- Stage orchestrator → Candidate ranker: ranks candidates (evidence: `backend/app/workflow.py`)
- Stage orchestrator → Validated records: validates outputs (evidence: `backend/app/workflow.py`)
