# robdima96/tri-back architecture

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

- Interactive diagram: https://gitdiagram.com/robdima96/tri-back
- Repository: https://github.com/robdima96/tri-back

## Overview

TRI-BACK is a research low-back triage prototype comprising a FastAPI/LangGraph chatbot, a Reflex study interface, and a local session browser. The main user journey is chat through the study UI to the bot, where intake and coverage support follow-up questions or disposition, with retrieval and graph services contributing clinical evidence; the bot returns a response and session record. The README documents the app roles, and sampled code confirms the chat API, its session writes, and the UI’s HTTP call. Internal orchestration and several service links are based on module names and documented capabilities; their exact wiring was not sampled.

Main entry points: [`bot/app/orchestrator/graph.py`](https://github.com/robdima96/tri-back/blob/main/bot/app/orchestrator/graph.py) (Triage orchestrator), [`prototypes/tri_back_study_app/tri_back_study_app/pages`](https://github.com/robdima96/tri-back/tree/main/prototypes/tri_back_study_app/tri_back_study_app/pages) (Study pages), [`bot/app/main.py`](https://github.com/robdima96/tri-back/blob/main/bot/app/main.py) (Chat API), [`bot/app/session_store.py`](https://github.com/robdima96/tri-back/blob/main/bot/app/session_store.py) (Bot session store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_study_ui["Study interface"]
  node_study_pages["Study pages"]
  node_chat_state["Chat state<br/>[chat_state.py]"]
  node_bot_client["Bot HTTP client<br/>[http_client.py]"]
end

subgraph group_bot_flow["Triage workflow"]
  node_bot_api["Chat API<br/>[main.py]"]
  node_triage_graph["Triage orchestrator<br/>[graph.py]"]
  node_intake["Intake planning"]
  node_coverage["Coverage evaluation<br/>[coverage.py]"]
  node_followup["Intake questions<br/>[intake_llm.py]"]
  node_disposition["Disposition brief"]
end

subgraph group_knowledge["Clinical knowledge"]
  node_rag["Evidence retrieval"]
  node_rag_store[("Chunk store<br/>[store.py]")]
  node_graph_rag["Graph traversal"]
  node_agentic_graph["Agentic graph RAG"]
end

subgraph group_session_tools["Session records"]
  node_bot_sessions[("Bot session store<br/>[session_store.py]")]
  node_study_overlay["Study session overlay<br/>[session_store.py]"]
  node_session_lab["Session browser<br/>[app.py]"]
end

node_participant(("Participant / admin"))
node_neo4j[("Neo4j graph")]
node_model["Language model"]

node_participant -->|"uses"| node_study_pages
node_study_pages -->|"updates"| node_chat_state
node_chat_state -->|"sends chat"| node_bot_client
node_bot_client -->|"calls"| node_bot_api
node_bot_api -->|"runs workflow"| node_triage_graph
node_triage_graph -->|"plans intake"| node_intake
node_triage_graph -->|"checks coverage"| node_coverage
node_triage_graph -->|"requests questions"| node_followup
node_triage_graph -->|"builds disposition"| node_disposition
node_triage_graph -->|"retrieves evidence"| node_rag
node_rag -->|"queries"| node_rag_store
node_triage_graph -->|"traverses graph"| node_graph_rag
node_graph_rag -.->|"queries"| node_neo4j
node_triage_graph -.->|"uses agent"| node_agentic_graph
node_agentic_graph -.->|"prompts"| node_model
node_bot_api -->|"saves session"| node_bot_sessions
node_study_pages -->|"records study data"| node_study_overlay
node_study_overlay -->|"overlays metadata"| node_bot_sessions
node_participant -->|"browses logs"| node_session_lab
node_session_lab -->|"reads sessions"| node_bot_sessions

click node_study_pages "https://github.com/robdima96/tri-back/tree/main/prototypes/tri_back_study_app/tri_back_study_app/pages"
click node_chat_state "https://github.com/robdima96/tri-back/blob/main/prototypes/tri_back_study_app/tri_back_study_app/state/chat_state.py"
click node_bot_client "https://github.com/robdima96/tri-back/blob/main/prototypes/tri_back_study_app/tri_back_study_app/adapters/http_client.py"
click node_bot_api "https://github.com/robdima96/tri-back/blob/main/bot/app/main.py"
click node_triage_graph "https://github.com/robdima96/tri-back/blob/main/bot/app/orchestrator/graph.py"
click node_intake "https://github.com/robdima96/tri-back/tree/main/bot/app/orchestrator"
click node_coverage "https://github.com/robdima96/tri-back/blob/main/bot/app/orchestrator/coverage.py"
click node_followup "https://github.com/robdima96/tri-back/blob/main/bot/app/services/intake_llm.py"
click node_disposition "https://github.com/robdima96/tri-back/blob/main/bot/app/services/disposition_brief.py"
click node_rag "https://github.com/robdima96/tri-back/tree/main/bot/app/services/rag"
click node_rag_store "https://github.com/robdima96/tri-back/blob/main/bot/app/services/rag/store.py"
click node_graph_rag "https://github.com/robdima96/tri-back/tree/main/bot/app/services/graphrag"
click node_agentic_graph "https://github.com/robdima96/tri-back/tree/main/bot/app/services/agentic_graph_rag"
click node_bot_sessions "https://github.com/robdima96/tri-back/blob/main/bot/app/session_store.py"
click node_study_overlay "https://github.com/robdima96/tri-back/blob/main/prototypes/tri_back_study_app/tri_back_study_app/session_store.py"
click node_session_lab "https://github.com/robdima96/tri-back/blob/main/Testing/app.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_study_pages,node_chat_state,node_bot_client toneBlue
class node_bot_api,node_triage_graph,node_intake,node_coverage,node_followup,node_disposition,node_neo4j toneAmber
class node_rag,node_rag_store,node_graph_rag,node_agentic_graph toneMint
class node_bot_sessions,node_study_overlay,node_session_lab toneRose
class node_participant,node_model toneIndigo
```

## Components

### Study interface

- [Study pages](https://github.com/robdima96/tri-back/tree/main/prototypes/tri_back_study_app/tri_back_study_app/pages): `prototypes/tri_back_study_app/tri_back_study_app/pages`
- [Chat state](https://github.com/robdima96/tri-back/blob/main/prototypes/tri_back_study_app/tri_back_study_app/state/chat_state.py): `prototypes/tri_back_study_app/tri_back_study_app/state/chat_state.py`
- [Bot HTTP client](https://github.com/robdima96/tri-back/blob/main/prototypes/tri_back_study_app/tri_back_study_app/adapters/http_client.py): `prototypes/tri_back_study_app/tri_back_study_app/adapters/http_client.py`

### Triage workflow

- [Chat API](https://github.com/robdima96/tri-back/blob/main/bot/app/main.py): `bot/app/main.py`
- [Triage orchestrator](https://github.com/robdima96/tri-back/blob/main/bot/app/orchestrator/graph.py): `bot/app/orchestrator/graph.py`
- [Intake planning](https://github.com/robdima96/tri-back/tree/main/bot/app/orchestrator): `bot/app/orchestrator`
- [Coverage evaluation](https://github.com/robdima96/tri-back/blob/main/bot/app/orchestrator/coverage.py): `bot/app/orchestrator/coverage.py`
- [Intake questions](https://github.com/robdima96/tri-back/blob/main/bot/app/services/intake_llm.py): `bot/app/services/intake_llm.py`
- [Disposition brief](https://github.com/robdima96/tri-back/blob/main/bot/app/services/disposition_brief.py): `bot/app/services/disposition_brief.py`

### Clinical knowledge

- [Evidence retrieval](https://github.com/robdima96/tri-back/tree/main/bot/app/services/rag): `bot/app/services/rag`
- [Chunk store](https://github.com/robdima96/tri-back/blob/main/bot/app/services/rag/store.py): `bot/app/services/rag/store.py`
- [Graph traversal](https://github.com/robdima96/tri-back/tree/main/bot/app/services/graphrag): `bot/app/services/graphrag`
- [Agentic graph RAG](https://github.com/robdima96/tri-back/tree/main/bot/app/services/agentic_graph_rag): `bot/app/services/agentic_graph_rag`

### Session records

- [Bot session store](https://github.com/robdima96/tri-back/blob/main/bot/app/session_store.py): `bot/app/session_store.py`
- [Study session overlay](https://github.com/robdima96/tri-back/blob/main/prototypes/tri_back_study_app/tri_back_study_app/session_store.py): `prototypes/tri_back_study_app/tri_back_study_app/session_store.py`
- [Session browser](https://github.com/robdima96/tri-back/blob/main/Testing/app.py): `Testing/app.py`

### Other components

- **Participant / admin**
- **Neo4j graph**
- **Language model**

## Connections

- Participant / admin → Study pages: uses
- Study pages → Chat state: updates
- Chat state → Bot HTTP client: sends chat
- Bot HTTP client → Chat API: calls
- Chat API → Triage orchestrator: runs workflow
- Triage orchestrator → Intake planning: plans intake
- Triage orchestrator → Coverage evaluation: checks coverage
- Triage orchestrator → Intake questions: requests questions
- Triage orchestrator → Disposition brief: builds disposition
- Triage orchestrator → Evidence retrieval: retrieves evidence
- Evidence retrieval → Chunk store: queries
- Triage orchestrator → Graph traversal: traverses graph
- Graph traversal → Neo4j graph: queries
- Triage orchestrator → Agentic graph RAG: uses agent
- Agentic graph RAG → Language model: prompts
- Chat API → Bot session store: saves session
- Study pages → Study session overlay: records study data
- Study session overlay → Bot session store: overlays metadata
- Participant / admin → Session browser: browses logs
- Session browser → Bot session store: reads sessions
