# datadrivenhumanities/ai-in-classics architecture

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

- Interactive diagram: https://gitdiagram.com/datadrivenhumanities/ai-in-classics
- Repository: https://github.com/datadrivenhumanities/ai-in-classics

## Overview

AI in Classics combines a text-analysis interface and backend with language-specific search and lemmatization tools; the tree also contains a separate Latin OCR application. The principal documented workflow is querying texts and receiving analysis, with chat, sentiment, feedback, model controls, and retraining as additional capabilities. The OCR upload-to-result path is directly evidenced by the sampled frontend and service. Several README-described features have unsampled implementations, so their nodes are included without speculative call edges.

Main entry points: [`src/app/app_functions.py`](https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/app/app_functions.py) (Query handler), [`src/frontend/src/components/Analyzer.tsx`](https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/frontend/src/components/Analyzer.tsx) (Analyzer UI), [`src/app/query.py`](https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/app/query.py) (Query page), [`src/Lemmatizer-LTN/api/db.py`](https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/Lemmatizer-LTN/api/db.py) (Latin database access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analysis_app["Analysis application"]
  node_analysis_ui["Analyzer UI<br/>[Analyzer.tsx]"]
  node_query_page["Query page<br/>[query.py]"]
  node_query_handler["Query handler<br/>[app_functions.py]"]
  node_chat_routes["Chat routes<br/>[chat_router.py]"]
  node_ollama_client["Ollama client<br/>[ollama_client.py]"]
  node_model_registry["Model registry<br/>[model_registry.py]"]
  node_sentiment["Sentiment analysis"]
  node_feedback["Feedback<br/>[feedback_router.py]"]
  node_presets["Model presets<br/>[presets_router.py]"]
  node_model_status["Model status<br/>[probing_router.py]"]
  node_training["Model training<br/>[train_router.py]"]
end

subgraph group_language_tools["Language tools"]
  node_greek_nlp["Greek lemmatization"]
  node_greek_dictionary["Greek dictionary queries<br/>[query.py]"]
  node_greek_storage[("Greek dictionary store<br/>[models.py]")]
  node_latin_api["Latin lemmatizer API<br/>[routes.py]"]
  node_latin_db["Latin database access<br/>[db.py]"]
  node_latin_store[("Latin dictionary store<br/>[db.py]")]
end

subgraph group_text_data["Text search and data"]
  node_data_collection["Text collection"]
  node_preprocessing["Query preprocessing"]
  node_text_search["Text search indexes"]
end

subgraph group_ocr_app["Latin OCR"]
  node_ocr_ui["OCR interface<br/>[App.jsx]"]
  node_ocr_service["OCR service<br/>[app.py]"]
  node_ocr_engine["OCR engines"]
end

node_user(("User"))
node_ocr_user(("OCR user"))

node_user -.->|"uses"| node_analysis_ui
node_analysis_ui -.->|"queries"| node_query_page
node_query_page -->|"calls"| node_query_handler
node_query_handler -->|"uses"| node_model_registry
node_query_handler -->|"calls"| node_ollama_client
node_chat_routes -->|"streams via"| node_ollama_client
node_sentiment -->|"uses"| node_query_handler
node_user -.->|"submits"| node_feedback
node_user -.->|"adjusts"| node_presets
node_user -.->|"checks"| node_model_status
node_user -.->|"requests"| node_training
node_greek_dictionary -->|"queries"| node_greek_storage
node_latin_api -->|"calls"| node_latin_db
node_latin_db -.->|"accesses"| node_latin_store
node_user -->|"uploads text"| node_ocr_ui
node_ocr_ui -->|"posts file"| node_ocr_service
node_ocr_service -.->|"recognizes text"| node_ocr_engine

click node_analysis_ui "https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/frontend/src/components/Analyzer.tsx"
click node_query_page "https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/app/query.py"
click node_query_handler "https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/app/app_functions.py"
click node_chat_routes "https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/app/routers/chat_router.py"
click node_ollama_client "https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/app/ollama_client.py"
click node_model_registry "https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/app/model_registry.py"
click node_sentiment "https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/app/routers/sentiment_router.py"
click node_feedback "https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/app/routers/feedback_router.py"
click node_presets "https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/app/routers/presets_router.py"
click node_model_status "https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/app/routers/probing_router.py"
click node_training "https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/app/routers/train_router.py"
click node_greek_nlp "https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/Lemmatizer-GRK-CLTK/GreekCLTKLemmatizer.py"
click node_greek_dictionary "https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/Lemmatizer-GRK/database/query.py"
click node_greek_storage "https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/Lemmatizer-GRK/database/models.py"
click node_latin_api "https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/Lemmatizer-LTN/api/routes.py"
click node_latin_db "https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/Lemmatizer-LTN/api/db.py"
click node_latin_store "https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/Lemmatizer-LTN/api/db.py"
click node_data_collection "https://github.com/datadrivenhumanities/ai-in-classics/tree/main/src/pipelines/data_collection"
click node_preprocessing "https://github.com/datadrivenhumanities/ai-in-classics/tree/main/src/pipelines/preprocessing/preprocess_root_query"
click node_text_search "https://github.com/datadrivenhumanities/ai-in-classics/tree/main/src/pipelines/text_search"
click node_ocr_ui "https://github.com/datadrivenhumanities/ai-in-classics/blob/main/Codex-Continuus/frontend/src/App.jsx"
click node_ocr_service "https://github.com/datadrivenhumanities/ai-in-classics/blob/main/Codex-Continuus/backend/ocr_service/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_analysis_ui,node_query_page,node_query_handler,node_chat_routes,node_ollama_client,node_model_registry,node_sentiment,node_feedback,node_presets,node_model_status,node_training,node_user,node_ocr_user toneBlue
class node_greek_nlp,node_greek_dictionary,node_greek_storage,node_latin_api,node_latin_db,node_latin_store toneAmber
class node_data_collection,node_preprocessing,node_text_search toneMint
class node_ocr_ui,node_ocr_service,node_ocr_engine toneRose
```

## Components

### Analysis application

- [Analyzer UI](https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/frontend/src/components/Analyzer.tsx): `src/frontend/src/components/Analyzer.tsx`
- [Query page](https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/app/query.py): `src/app/query.py`
- [Query handler](https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/app/app_functions.py): `src/app/app_functions.py`
- [Chat routes](https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/app/routers/chat_router.py): `src/app/routers/chat_router.py`
- [Ollama client](https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/app/ollama_client.py): `src/app/ollama_client.py`
- [Model registry](https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/app/model_registry.py): `src/app/model_registry.py`
- [Sentiment analysis](https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/app/routers/sentiment_router.py): `src/app/routers/sentiment_router.py`
- [Feedback](https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/app/routers/feedback_router.py): `src/app/routers/feedback_router.py`
- [Model presets](https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/app/routers/presets_router.py): `src/app/routers/presets_router.py`
- [Model status](https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/app/routers/probing_router.py): `src/app/routers/probing_router.py`
- [Model training](https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/app/routers/train_router.py): `src/app/routers/train_router.py`

### Language tools

- [Greek lemmatization](https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/Lemmatizer-GRK-CLTK/GreekCLTKLemmatizer.py): `src/Lemmatizer-GRK-CLTK/GreekCLTKLemmatizer.py`
- [Greek dictionary queries](https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/Lemmatizer-GRK/database/query.py): `src/Lemmatizer-GRK/database/query.py`
- [Greek dictionary store](https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/Lemmatizer-GRK/database/models.py): `src/Lemmatizer-GRK/database/models.py`
- [Latin lemmatizer API](https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/Lemmatizer-LTN/api/routes.py): `src/Lemmatizer-LTN/api/routes.py`
- [Latin database access](https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/Lemmatizer-LTN/api/db.py): `src/Lemmatizer-LTN/api/db.py`
- [Latin dictionary store](https://github.com/datadrivenhumanities/ai-in-classics/blob/main/src/Lemmatizer-LTN/api/db.py): `src/Lemmatizer-LTN/api/db.py`

### Text search and data

- [Text collection](https://github.com/datadrivenhumanities/ai-in-classics/tree/main/src/pipelines/data_collection): `src/pipelines/data_collection`
- [Query preprocessing](https://github.com/datadrivenhumanities/ai-in-classics/tree/main/src/pipelines/preprocessing/preprocess_root_query): `src/pipelines/preprocessing/preprocess_root_query`
- [Text search indexes](https://github.com/datadrivenhumanities/ai-in-classics/tree/main/src/pipelines/text_search): `src/pipelines/text_search`

### Latin OCR

- [OCR interface](https://github.com/datadrivenhumanities/ai-in-classics/blob/main/Codex-Continuus/frontend/src/App.jsx): `Codex-Continuus/frontend/src/App.jsx`
- [OCR service](https://github.com/datadrivenhumanities/ai-in-classics/blob/main/Codex-Continuus/backend/ocr_service/app.py): `Codex-Continuus/backend/ocr_service/app.py`
- **OCR engines**

### Other components

- **User**
- **OCR user**

## Connections

- User → Analyzer UI: uses (evidence: `README.md`)
- Analyzer UI → Query page: queries
- Query page → Query handler: calls (evidence: `src/app/query.py`)
- Query handler → Model registry: uses (evidence: `src/app/app_functions.py`)
- Query handler → Ollama client: calls (evidence: `src/app/app_functions.py`)
- Chat routes → Ollama client: streams via (evidence: `src/app/routers/chat_router.py`)
- Sentiment analysis → Query handler: uses (evidence: `src/app/routers/sentiment_router.py`)
- User → Feedback: submits (evidence: `README.md`)
- User → Model presets: adjusts (evidence: `README.md`)
- User → Model status: checks (evidence: `README.md`)
- User → Model training: requests (evidence: `README.md`)
- Greek dictionary queries → Greek dictionary store: queries (evidence: `src/Lemmatizer-GRK/database/query.py`)
- Latin lemmatizer API → Latin database access: calls (evidence: `src/Lemmatizer-LTN/api/routes.py`)
- Latin database access → Latin dictionary store: accesses (evidence: `src/Lemmatizer-LTN/api/db.py`)
- User → OCR interface: uploads text (evidence: `Codex-Continuus/frontend/src/App.jsx`)
- OCR interface → OCR service: posts file (evidence: `Codex-Continuus/frontend/src/App.jsx`)
- OCR service → OCR engines: recognizes text
