# kanimozhis-877/try-catch-us architecture

> Architecture diagram of the GitHub repository kanimozhis-877/try-catch-us, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kanimozhis-877/try-catch-us
- Repository: https://github.com/kanimozhis-877/try-catch-us

## Overview

Healthcare Information Platform organizes patient profiles and medical reports, with AI-generated clinical context as a central capability. The main evidenced workflow is client request → FastAPI routes → domain services → MongoDB; report context can also be assembled for AI analysis, while QR sessions provide temporary access. The graph includes documented route families beyond the sampled handlers, but omits their internal links where source was not shown.

Main entry points: [`backend/database/mongodb.py`](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/database/mongodb.py) (MongoDB), [`backend/routes/patient_routes.py`](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/routes/patient_routes.py) (Patient routes), [`backend/app/main.py`](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/app/main.py) (HTTP application), [`backend/services/auth_service.py`](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/services/auth_service.py) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API and identity"]
  node_api["HTTP application<br/>[main.py]"]
  node_auth_routes["Authentication routes<br/>[auth_routes.py]"]
  node_auth_service["Authentication<br/>[auth_service.py]"]
  node_jwt["Token signing<br/>[jwt_handler.py]"]
  node_dependencies["Access control<br/>[dependencies.py]"]
end

subgraph group_care["Patient records"]
  node_patient_routes["Patient routes<br/>[patient_routes.py]"]
  node_patient_service["Patient profiles<br/>[patient_service.py]"]
  node_uploads["Medical uploads<br/>[upload_routes.py]"]
  node_records["Medical records"]
  node_reports["Report management<br/>[report_service.py]"]
  node_labs["Lab results"]
  node_doctors["Doctor directory<br/>[doctor_routes.py]"]
  node_emergency["Emergency access"]
end

subgraph group_insights["Clinical insights"]
  node_ai_routes["AI analysis routes<br/>[ai_routes.py]"]
  node_ai_service["AI orchestration<br/>[ai_service.py]"]
  node_context["Patient context<br/>[context_engine.py]"]
  node_ollama["Language model client<br/>[ollama_client.py]"]
  node_comparison["Record comparison"]
  node_dashboard["Clinical dashboard"]
end

subgraph group_persistence["Data and access"]
  node_qr_routes["QR access routes<br/>[qr_routes.py]"]
  node_qr_service["QR sessions<br/>[qr_service.py]"]
  node_language["Language preferences"]
  node_mongo[("MongoDB<br/>[mongodb.py]")]
  node_repositories["Repository base<br/>[base_repository.py]"]
end

node_client(("API client"))
node_ollama_service["Ollama endpoint"]

node_client -->|"sends requests"| node_api
node_api -->|"registers router"| node_auth_routes
node_api -->|"registers router"| node_patient_routes
node_auth_routes -->|"calls"| node_auth_service
node_auth_service -->|"reads and writes"| node_mongo
node_auth_service -->|"creates token"| node_jwt
node_patient_routes -->|"calls"| node_patient_service
node_patient_routes -->|"uploads and manages reports"| node_reports
node_ai_routes -->|"calls"| node_ai_service
node_ai_service -->|"builds context"| node_context
node_ai_service -->|"requests generation"| node_ollama
node_context -->|"reads patient data"| node_mongo
node_ollama -.->|"posts prompt"| node_ollama_service
node_qr_routes -->|"calls"| node_qr_service
node_qr_service -->|"reads and writes"| node_mongo
node_patient_routes -.->|"uses auth dependency"| node_dependencies
node_dependencies -.->|"verifies token"| node_jwt
node_repositories -->|"uses database"| node_mongo
node_uploads -.->|"stores upload metadata"| node_mongo
node_records -.->|"accesses records"| node_mongo
node_labs -.->|"accesses results"| node_mongo
node_doctors -.->|"accesses directory"| node_mongo
node_emergency -.->|"accesses emergency data"| node_mongo
node_comparison -.->|"compares records"| node_mongo
node_dashboard -->|"reads summaries"| node_mongo
node_language -->|"stores preferences"| node_mongo

click node_api "https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/app/main.py"
click node_auth_routes "https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/routes/auth_routes.py"
click node_auth_service "https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/services/auth_service.py"
click node_jwt "https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/security/jwt_handler.py"
click node_dependencies "https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/app/dependencies.py"
click node_patient_routes "https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/routes/patient_routes.py"
click node_patient_service "https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/services/patient_service.py"
click node_uploads "https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/routes/upload_routes.py"
click node_records "https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/routes/medical_record_routes.py"
click node_reports "https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/services/report_service.py"
click node_labs "https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/routes/lab_result_routes.py"
click node_doctors "https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/routes/doctor_routes.py"
click node_emergency "https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/routes/emergency_routes.py"
click node_ai_routes "https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/routes/ai_routes.py"
click node_ai_service "https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/services/ai_service.py"
click node_context "https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/ai/context_engine.py"
click node_ollama "https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/ai/ollama_client.py"
click node_comparison "https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/routes/comparison_routes.py"
click node_dashboard "https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/routes/dashboard_routes.py"
click node_qr_routes "https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/routes/qr_routes.py"
click node_qr_service "https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/services/qr_service.py"
click node_language "https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/services/language_service.py"
click node_mongo "https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/database/mongodb.py"
click node_repositories "https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/database/repositories/base_repository.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_api,node_auth_routes,node_auth_service,node_jwt,node_dependencies,node_client toneBlue
class node_patient_routes,node_patient_service,node_uploads,node_records,node_reports,node_labs,node_doctors,node_emergency toneAmber
class node_ai_routes,node_ai_service,node_context,node_ollama,node_comparison,node_dashboard toneMint
class node_qr_routes,node_qr_service,node_language,node_mongo,node_repositories toneRose
class node_ollama_service toneIndigo
```

## Components

### API and identity

- [HTTP application](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication routes](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/routes/auth_routes.py): `backend/routes/auth_routes.py`
- [Authentication](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/services/auth_service.py): `backend/services/auth_service.py`
- [Token signing](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/security/jwt_handler.py): `backend/security/jwt_handler.py`
- [Access control](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/app/dependencies.py): `backend/app/dependencies.py`

### Patient records

- [Patient routes](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/routes/patient_routes.py): `backend/routes/patient_routes.py`
- [Patient profiles](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/services/patient_service.py): `backend/services/patient_service.py`
- [Medical uploads](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/routes/upload_routes.py): `backend/routes/upload_routes.py`
- [Medical records](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/routes/medical_record_routes.py): `backend/routes/medical_record_routes.py`
- [Report management](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/services/report_service.py): `backend/services/report_service.py`
- [Lab results](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/routes/lab_result_routes.py): `backend/routes/lab_result_routes.py`
- [Doctor directory](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/routes/doctor_routes.py): `backend/routes/doctor_routes.py`
- [Emergency access](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/routes/emergency_routes.py): `backend/routes/emergency_routes.py`

### Clinical insights

- [AI analysis routes](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/routes/ai_routes.py): `backend/routes/ai_routes.py`
- [AI orchestration](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/services/ai_service.py): `backend/services/ai_service.py`
- [Patient context](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/ai/context_engine.py): `backend/ai/context_engine.py`
- [Language model client](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/ai/ollama_client.py): `backend/ai/ollama_client.py`
- [Record comparison](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/routes/comparison_routes.py): `backend/routes/comparison_routes.py`
- [Clinical dashboard](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/routes/dashboard_routes.py): `backend/routes/dashboard_routes.py`

### Data and access

- [QR access routes](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/routes/qr_routes.py): `backend/routes/qr_routes.py`
- [QR sessions](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/services/qr_service.py): `backend/services/qr_service.py`
- [Language preferences](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/services/language_service.py): `backend/services/language_service.py`
- [MongoDB](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/database/mongodb.py): `backend/database/mongodb.py`
- [Repository base](https://github.com/kanimozhis-877/try-catch-us/blob/main/backend/database/repositories/base_repository.py): `backend/database/repositories/base_repository.py`

### Other components

- **API client**
- **Ollama endpoint**

## Connections

- API client → HTTP application: sends requests (evidence: `backend/app/main.py`)
- HTTP application → Authentication routes: registers router (evidence: `backend/app/main.py`)
- HTTP application → Patient routes: registers router (evidence: `backend/app/main.py`)
- Authentication routes → Authentication: calls (evidence: `backend/routes/auth_routes.py`)
- Authentication → MongoDB: reads and writes (evidence: `backend/services/auth_service.py`)
- Authentication → Token signing: creates token (evidence: `backend/services/auth_service.py`)
- Patient routes → Patient profiles: calls (evidence: `backend/routes/patient_routes.py`)
- Patient routes → Report management: uploads and manages reports (evidence: `backend/routes/patient_routes.py`)
- AI analysis routes → AI orchestration: calls (evidence: `backend/routes/ai_routes.py`)
- AI orchestration → Patient context: builds context (evidence: `backend/services/ai_service.py`)
- AI orchestration → Language model client: requests generation (evidence: `backend/services/ai_service.py`)
- Patient context → MongoDB: reads patient data (evidence: `backend/ai/context_engine.py`)
- Language model client → Ollama endpoint: posts prompt
- QR access routes → QR sessions: calls (evidence: `backend/routes/qr_routes.py`)
- QR sessions → MongoDB: reads and writes (evidence: `backend/services/qr_service.py`)
- Patient routes → Access control: uses auth dependency
- Access control → Token signing: verifies token
- Repository base → MongoDB: uses database (evidence: `backend/database/repositories/base_repository.py`)
- Medical uploads → MongoDB: stores upload metadata
- Medical records → MongoDB: accesses records
- Lab results → MongoDB: accesses results
- Doctor directory → MongoDB: accesses directory
- Emergency access → MongoDB: accesses emergency data
- Record comparison → MongoDB: compares records
- Clinical dashboard → MongoDB: reads summaries (evidence: `backend/routes/dashboard_routes.py`)
- Language preferences → MongoDB: stores preferences (evidence: `backend/services/language_service.py`)
