# artemmukh/dental-flux-ai architecture

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

- Interactive diagram: https://gitdiagram.com/artemmukh/dental-flux-ai
- Repository: https://github.com/artemmukh/dental-flux-ai

## Overview

Dental Flux AI is a backend prototype for reviewing panoramic dental X-rays: a session accepts an image, runs tooth/findings analysis, supports clinician corrections, and produces a draft report for confirmation. Confirmed sessions can feed correction/export data. The README also describes anonymized LLM reporting and validation. The sampled code shows orchestration and storage, but not every API or ML implementation; edges below use indexed references, excerpts, or README statements rather than assuming an unsampled pipeline.

Main entry points: [`backend/app/core/mock_state.py`](https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/core/mock_state.py) (Session orchestration), [`backend/app/main.py`](https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/main.py) (API application), [`backend/app/llm/report_gen.py`](https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/llm/report_gen.py) (Report generation), [`backend/app/core/mutations.py`](https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/core/mutations.py) (Edit mutations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and sessions"]
  node_app["API application<br/>[main.py]"]
  node_sessions_api["Session endpoints<br/>[sessions.py]"]
  node_findings_api["Finding endpoints<br/>[findings.py]"]
  node_chat_api["Chat endpoint<br/>[chat.py]"]
  node_confirm_api["Confirmation endpoint<br/>[confirm.py]"]
  node_log_api["Edit log endpoint<br/>[log.py]"]
  node_overlay_api["Overlay endpoint<br/>[overlay.py]"]
  node_export_api["Export endpoint<br/>[export.py]"]
  node_report_api["Report endpoint<br/>[report.py]"]
  node_orchestrator["Session orchestration<br/>[mock_state.py]"]
end

subgraph group_analysis["Image analysis"]
  node_ml["ML backends"]
  node_enrichment["Finding enrichment<br/>[enrich.py]"]
end

subgraph group_review["Clinical review"]
  node_edits["Edit mutations<br/>[mutations.py]"]
  node_fdi["FDI rules<br/>[fdi.py]"]
end

subgraph group_reporting["Reports and LLM"]
  node_report_gen["Report generation<br/>[report_gen.py]"]
  node_report_views["Formula and review views"]
  node_validator["LLM validator<br/>[validator.py]"]
  node_llm_client["OpenRouter client<br/>[client.py]"]
  node_fallback["Fallback report<br/>[fallback.py]"]
end

subgraph group_data["Persistence and export"]
  node_store[("Session store<br/>[store.py]")]
  node_export["Dataset exports"]
end

node_clinician(("Clinician"))
node_image["Panoramic image"]
node_openrouter(("OpenRouter<br/>external service"))

node_image -->|"uploads"| node_sessions_api
node_clinician -->|"uses API"| node_app
node_app -->|"routes"| node_sessions_api
node_app -->|"routes"| node_findings_api
node_app -->|"routes"| node_chat_api
node_app -->|"routes"| node_confirm_api
node_app -->|"routes"| node_log_api
node_app -->|"routes"| node_overlay_api
node_app -->|"routes"| node_export_api
node_app -->|"routes"| node_report_api
node_sessions_api -->|"delegates"| node_orchestrator
node_findings_api -->|"delegates"| node_orchestrator
node_chat_api -->|"delegates"| node_orchestrator
node_confirm_api -->|"delegates"| node_orchestrator
node_log_api -->|"delegates"| node_orchestrator
node_overlay_api -->|"delegates"| node_orchestrator
node_export_api -->|"delegates"| node_orchestrator
node_report_api -->|"delegates"| node_orchestrator
node_orchestrator -->|"runs inference"| node_ml
node_orchestrator -->|"enriches findings"| node_enrichment
node_orchestrator -->|"reads and writes"| node_store
node_orchestrator -->|"applies edits"| node_edits
node_edits -->|"validates numbers"| node_fdi
node_edits -->|"records edits"| node_store
node_orchestrator -->|"builds report"| node_report_gen
node_report_gen -->|"requests completion"| node_llm_client
node_report_gen -->|"validates draft"| node_validator
node_report_gen -->|"falls back"| node_fallback
node_report_gen -->|"builds report views"| node_report_views
node_report_views -->|"uses FDI rules"| node_fdi
node_llm_client -.->|"calls service"| node_openrouter
node_orchestrator -->|"exports sessions"| node_export
node_export -->|"reads confirmed data"| node_store

click node_app "https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/main.py"
click node_sessions_api "https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/api/sessions.py"
click node_findings_api "https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/api/findings.py"
click node_chat_api "https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/api/chat.py"
click node_confirm_api "https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/api/confirm.py"
click node_log_api "https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/api/log.py"
click node_overlay_api "https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/api/overlay.py"
click node_export_api "https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/api/export.py"
click node_report_api "https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/api/report.py"
click node_orchestrator "https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/core/mock_state.py"
click node_ml "https://github.com/artemmukh/dental-flux-ai/tree/main/backend/app/ml"
click node_enrichment "https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/ml/enrich.py"
click node_edits "https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/core/mutations.py"
click node_fdi "https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/core/fdi.py"
click node_report_gen "https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/llm/report_gen.py"
click node_report_views "https://github.com/artemmukh/dental-flux-ai/tree/main/backend/app/report"
click node_validator "https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/llm/validator.py"
click node_llm_client "https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/llm/client.py"
click node_fallback "https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/llm/fallback.py"
click node_store "https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/core/store.py"
click node_export "https://github.com/artemmukh/dental-flux-ai/tree/main/backend/app/export"

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_sessions_api,node_findings_api,node_chat_api,node_confirm_api,node_log_api,node_overlay_api,node_export_api,node_report_api,node_orchestrator toneBlue
class node_ml,node_enrichment toneAmber
class node_edits,node_fdi,node_openrouter toneMint
class node_report_gen,node_report_views,node_validator,node_llm_client,node_fallback toneRose
class node_store,node_export,node_clinician,node_image toneIndigo
```

## Components

### API and sessions

- [API application](https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/main.py): `backend/app/main.py`
- [Session endpoints](https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/api/sessions.py): `backend/app/api/sessions.py`
- [Finding endpoints](https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/api/findings.py): `backend/app/api/findings.py`
- [Chat endpoint](https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/api/chat.py): `backend/app/api/chat.py`
- [Confirmation endpoint](https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/api/confirm.py): `backend/app/api/confirm.py`
- [Edit log endpoint](https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/api/log.py): `backend/app/api/log.py`
- [Overlay endpoint](https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/api/overlay.py): `backend/app/api/overlay.py`
- [Export endpoint](https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/api/export.py): `backend/app/api/export.py`
- [Report endpoint](https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/api/report.py): `backend/app/api/report.py`
- [Session orchestration](https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/core/mock_state.py): `backend/app/core/mock_state.py`

### Image analysis

- [ML backends](https://github.com/artemmukh/dental-flux-ai/tree/main/backend/app/ml): `backend/app/ml`
- [Finding enrichment](https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/ml/enrich.py): `backend/app/ml/enrich.py`

### Clinical review

- [Edit mutations](https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/core/mutations.py): `backend/app/core/mutations.py`
- [FDI rules](https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/core/fdi.py): `backend/app/core/fdi.py`

### Reports and LLM

- [Report generation](https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/llm/report_gen.py): `backend/app/llm/report_gen.py`
- [Formula and review views](https://github.com/artemmukh/dental-flux-ai/tree/main/backend/app/report): `backend/app/report`
- [LLM validator](https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/llm/validator.py): `backend/app/llm/validator.py`
- [OpenRouter client](https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/llm/client.py): `backend/app/llm/client.py`
- [Fallback report](https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/llm/fallback.py): `backend/app/llm/fallback.py`

### Persistence and export

- [Session store](https://github.com/artemmukh/dental-flux-ai/blob/main/backend/app/core/store.py): `backend/app/core/store.py`
- [Dataset exports](https://github.com/artemmukh/dental-flux-ai/tree/main/backend/app/export): `backend/app/export`

### Other components

- **Clinician**
- **Panoramic image**
- **OpenRouter**: external service

## Connections

- Panoramic image → Session endpoints: uploads (evidence: `README.md`)
- Clinician → API application: uses API (evidence: `README.md`)
- API application → Session endpoints: routes (evidence: `backend/app/main.py`)
- API application → Finding endpoints: routes (evidence: `backend/app/main.py`)
- API application → Chat endpoint: routes (evidence: `backend/app/main.py`)
- API application → Confirmation endpoint: routes (evidence: `backend/app/main.py`)
- API application → Edit log endpoint: routes (evidence: `backend/app/main.py`)
- API application → Overlay endpoint: routes (evidence: `backend/app/main.py`)
- API application → Export endpoint: routes (evidence: `backend/app/main.py`)
- API application → Report endpoint: routes (evidence: `backend/app/main.py`)
- Session endpoints → Session orchestration: delegates (evidence: `backend/app/api/sessions.py`)
- Finding endpoints → Session orchestration: delegates (evidence: `backend/app/api/findings.py`)
- Chat endpoint → Session orchestration: delegates (evidence: `backend/app/api/chat.py`)
- Confirmation endpoint → Session orchestration: delegates (evidence: `backend/app/api/confirm.py`)
- Edit log endpoint → Session orchestration: delegates (evidence: `backend/app/api/log.py`)
- Overlay endpoint → Session orchestration: delegates (evidence: `backend/app/api/overlay.py`)
- Export endpoint → Session orchestration: delegates (evidence: `backend/app/api/export.py`)
- Report endpoint → Session orchestration: delegates (evidence: `backend/app/api/report.py`)
- Session orchestration → ML backends: runs inference (evidence: `backend/app/core/mock_state.py`)
- Session orchestration → Finding enrichment: enriches findings (evidence: `backend/app/core/mock_state.py`)
- Session orchestration → Session store: reads and writes (evidence: `backend/app/core/mock_state.py`)
- Session orchestration → Edit mutations: applies edits (evidence: `backend/app/core/mock_state.py`)
- Edit mutations → FDI rules: validates numbers (evidence: `backend/app/core/mutations.py`)
- Edit mutations → Session store: records edits (evidence: `backend/app/core/mutations.py`)
- Session orchestration → Report generation: builds report (evidence: `backend/app/core/mock_state.py`)
- Report generation → OpenRouter client: requests completion (evidence: `backend/app/llm/report_gen.py`)
- Report generation → LLM validator: validates draft (evidence: `backend/app/llm/report_gen.py`)
- Report generation → Fallback report: falls back (evidence: `backend/app/llm/report_gen.py`)
- Report generation → Formula and review views: builds report views (evidence: `backend/app/llm/report_gen.py`)
- Formula and review views → FDI rules: uses FDI rules (evidence: `backend/app/report/review_list.py`)
- OpenRouter client → OpenRouter: calls service (evidence: `README.md`)
- Session orchestration → Dataset exports: exports sessions (evidence: `backend/app/core/mock_state.py`)
- Dataset exports → Session store: reads confirmed data (evidence: `backend/app/export/__init__.py`)
