# karimtawfikk/echo architecture

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

- Interactive diagram: https://gitdiagram.com/karimtawfikk/echo
- Repository: https://github.com/karimtawfikk/echo

## Overview

ECHO presents an Ancient Egypt exploration workflow: users browse or upload an artifact, then receive recognition, historical chat, hieroglyph translation, or generated video. The frontend calls a FastAPI gateway that routes feature requests to dedicated AI services; PostgreSQL and Cloudflare R2 support documented data and media operations. The graph preserves these major product capabilities. Internal service-to-runtime links are shown where excerpts demonstrate calls; gateway-to-service and external storage links rely on README architecture documentation, since route implementations and some service internals were not sampled.

Main entry points: [`src/app/main.py`](https://github.com/karimtawfikk/echo/blob/main/src/app/main.py) (FastAPI gateway), [`frontend/app/page.tsx`](https://github.com/karimtawfikk/echo/blob/main/frontend/app/page.tsx) (Explore home), [`frontend/app/chat/page.tsx`](https://github.com/karimtawfikk/echo/blob/main/frontend/app/chat/page.tsx) (Historical chat), [`src/recognition_api/app.py`](https://github.com/karimtawfikk/echo/blob/main/src/recognition_api/app.py) (Recognition API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User experience"]
  node_home["Explore home<br/>[page.tsx]"]
  node_upload["Image upload<br/>[page.tsx]"]
  node_results["Recognition results<br/>[page.tsx]"]
  node_chatui["Historical chat<br/>[page.tsx]"]
  node_translateui["Translation UI<br/>[page.tsx]"]
  node_videoui["Video UI<br/>[page.tsx]"]
  node_shell["Page shell<br/>[PageShell.tsx]"]
  node_language["Language context"]
  node_recognitionclient["Recognition client<br/>[recognition.ts]"]
end

subgraph group_gateway["API gateway"]
  node_gateway["FastAPI gateway<br/>[main.py]"]
  node_recognitionroute["Recognition route<br/>[recognize.py]"]
  node_chatroute["Chat route<br/>[chat.py]"]
  node_hieroroute["Hieroglyph route<br/>[hieroglyphs.py]"]
  node_videoroute["Video route<br/>[video.py]"]
end

subgraph group_ai["AI services"]
  node_recognitionapp["Recognition API<br/>[app.py]"]
  node_recognitionruntime["Recognition pipeline<br/>[runtime.py]"]
  node_chatapp["Chatbot API<br/>[app.py]"]
  node_chatservice["Chat service<br/>[service.py]"]
  node_chatruntime["RAG and voice runtime<br/>[runtime.py]"]
  node_hieroapp["Hieroglyph API<br/>[app.py]"]
  node_hieroservice["Detection service<br/>[service.py]"]
  node_hieroruntime["Detection pipeline<br/>[runtime.py]"]
  node_videoapp["Video API<br/>[app.py]"]
  node_videoruntime["Video pipeline<br/>[runtime.py]"]
end

subgraph group_data["Data and storage"]
  node_postgres[("PostgreSQL")]
  node_r2[("Cloudflare R2")]
end

node_user(("Visitor"))

node_user -->|"browses"| node_home
node_home -->|"opens"| node_upload
node_upload -->|"submits image"| node_gateway
node_gateway -->|"routes"| node_recognitionroute
node_recognitionroute -.->|"forwards request"| node_recognitionapp
node_recognitionapp -->|"runs inference"| node_recognitionruntime
node_recognitionapp -.->|"returns recognition"| node_results
node_results -.->|"starts conversation"| node_chatui
node_chatui -->|"sends prompt"| node_gateway
node_gateway -->|"routes"| node_chatroute
node_chatroute -.->|"forwards request"| node_chatapp
node_chatapp -->|"dispatches"| node_chatservice
node_chatservice -->|"calls"| node_chatruntime
node_chatruntime -.->|"queries context"| node_postgres
node_user -->|"uploads inscription"| node_translateui
node_translateui -->|"requests translation"| node_gateway
node_gateway -->|"routes"| node_hieroroute
node_hieroroute -.->|"forwards request"| node_hieroapp
node_hieroapp -->|"dispatches"| node_hieroservice
node_hieroservice -->|"runs pipeline"| node_hieroruntime
node_user -->|"requests video"| node_videoui
node_videoui -->|"requests generation"| node_gateway
node_gateway -->|"routes"| node_videoroute
node_videoroute -.->|"forwards request"| node_videoapp
node_videoapp -->|"dispatches"| node_videoruntime
node_videoruntime -.->|"retrieves media metadata"| node_postgres
node_videoruntime -.->|"fetches images"| node_r2
node_home -.->|"renders"| node_shell
node_chatui -->|"loads session result"| node_recognitionclient
node_shell -->|"uses translations"| node_language
node_recognitionclient -.->|"provides result data"| node_results

click node_home "https://github.com/karimtawfikk/echo/blob/main/frontend/app/page.tsx"
click node_upload "https://github.com/karimtawfikk/echo/blob/main/frontend/app/upload/page.tsx"
click node_results "https://github.com/karimtawfikk/echo/blob/main/frontend/app/result/page.tsx"
click node_chatui "https://github.com/karimtawfikk/echo/blob/main/frontend/app/chat/page.tsx"
click node_translateui "https://github.com/karimtawfikk/echo/blob/main/frontend/app/translate/page.tsx"
click node_videoui "https://github.com/karimtawfikk/echo/blob/main/frontend/app/video/page.tsx"
click node_shell "https://github.com/karimtawfikk/echo/blob/main/frontend/components/layout/PageShell.tsx"
click node_language "https://github.com/karimtawfikk/echo/blob/main/frontend/context/LanguageContext.tsx"
click node_recognitionclient "https://github.com/karimtawfikk/echo/blob/main/frontend/lib/services/recognition.ts"
click node_gateway "https://github.com/karimtawfikk/echo/blob/main/src/app/main.py"
click node_recognitionroute "https://github.com/karimtawfikk/echo/blob/main/src/app/api/routes/recognize.py"
click node_chatroute "https://github.com/karimtawfikk/echo/blob/main/src/app/api/routes/chat.py"
click node_hieroroute "https://github.com/karimtawfikk/echo/blob/main/src/app/api/routes/hieroglyphs.py"
click node_videoroute "https://github.com/karimtawfikk/echo/blob/main/src/app/api/routes/video.py"
click node_recognitionapp "https://github.com/karimtawfikk/echo/blob/main/src/recognition_api/app.py"
click node_recognitionruntime "https://github.com/karimtawfikk/echo/blob/main/src/recognition_api/runtime.py"
click node_chatapp "https://github.com/karimtawfikk/echo/blob/main/src/chatbot_api/app.py"
click node_chatservice "https://github.com/karimtawfikk/echo/blob/main/src/chatbot_api/service.py"
click node_chatruntime "https://github.com/karimtawfikk/echo/blob/main/src/chatbot_api/runtime.py"
click node_hieroapp "https://github.com/karimtawfikk/echo/blob/main/src/hieroglyph_api/app.py"
click node_hieroservice "https://github.com/karimtawfikk/echo/blob/main/src/hieroglyph_api/service.py"
click node_hieroruntime "https://github.com/karimtawfikk/echo/blob/main/src/hieroglyph_api/runtime.py"
click node_videoapp "https://github.com/karimtawfikk/echo/blob/main/src/video_generation_api/app.py"
click node_videoruntime "https://github.com/karimtawfikk/echo/blob/main/src/video_generation_api/runtime.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_home,node_upload,node_results,node_chatui,node_translateui,node_videoui,node_shell,node_language,node_recognitionclient toneBlue
class node_gateway,node_recognitionroute,node_chatroute,node_hieroroute,node_videoroute toneAmber
class node_recognitionapp,node_recognitionruntime,node_chatapp,node_chatservice,node_chatruntime,node_hieroapp,node_hieroservice,node_hieroruntime,node_videoapp,node_videoruntime toneMint
class node_postgres,node_r2 toneRose
class node_user toneIndigo
```

## Components

### User experience

- [Explore home](https://github.com/karimtawfikk/echo/blob/main/frontend/app/page.tsx): `frontend/app/page.tsx`
- [Image upload](https://github.com/karimtawfikk/echo/blob/main/frontend/app/upload/page.tsx): `frontend/app/upload/page.tsx`
- [Recognition results](https://github.com/karimtawfikk/echo/blob/main/frontend/app/result/page.tsx): `frontend/app/result/page.tsx`
- [Historical chat](https://github.com/karimtawfikk/echo/blob/main/frontend/app/chat/page.tsx): `frontend/app/chat/page.tsx`
- [Translation UI](https://github.com/karimtawfikk/echo/blob/main/frontend/app/translate/page.tsx): `frontend/app/translate/page.tsx`
- [Video UI](https://github.com/karimtawfikk/echo/blob/main/frontend/app/video/page.tsx): `frontend/app/video/page.tsx`
- [Page shell](https://github.com/karimtawfikk/echo/blob/main/frontend/components/layout/PageShell.tsx): `frontend/components/layout/PageShell.tsx`
- [Language context](https://github.com/karimtawfikk/echo/blob/main/frontend/context/LanguageContext.tsx): `frontend/context/LanguageContext.tsx`
- [Recognition client](https://github.com/karimtawfikk/echo/blob/main/frontend/lib/services/recognition.ts): `frontend/lib/services/recognition.ts`

### API gateway

- [FastAPI gateway](https://github.com/karimtawfikk/echo/blob/main/src/app/main.py): `src/app/main.py`
- [Recognition route](https://github.com/karimtawfikk/echo/blob/main/src/app/api/routes/recognize.py): `src/app/api/routes/recognize.py`
- [Chat route](https://github.com/karimtawfikk/echo/blob/main/src/app/api/routes/chat.py): `src/app/api/routes/chat.py`
- [Hieroglyph route](https://github.com/karimtawfikk/echo/blob/main/src/app/api/routes/hieroglyphs.py): `src/app/api/routes/hieroglyphs.py`
- [Video route](https://github.com/karimtawfikk/echo/blob/main/src/app/api/routes/video.py): `src/app/api/routes/video.py`

### AI services

- [Recognition API](https://github.com/karimtawfikk/echo/blob/main/src/recognition_api/app.py): `src/recognition_api/app.py`
- [Recognition pipeline](https://github.com/karimtawfikk/echo/blob/main/src/recognition_api/runtime.py): `src/recognition_api/runtime.py`
- [Chatbot API](https://github.com/karimtawfikk/echo/blob/main/src/chatbot_api/app.py): `src/chatbot_api/app.py`
- [Chat service](https://github.com/karimtawfikk/echo/blob/main/src/chatbot_api/service.py): `src/chatbot_api/service.py`
- [RAG and voice runtime](https://github.com/karimtawfikk/echo/blob/main/src/chatbot_api/runtime.py): `src/chatbot_api/runtime.py`
- [Hieroglyph API](https://github.com/karimtawfikk/echo/blob/main/src/hieroglyph_api/app.py): `src/hieroglyph_api/app.py`
- [Detection service](https://github.com/karimtawfikk/echo/blob/main/src/hieroglyph_api/service.py): `src/hieroglyph_api/service.py`
- [Detection pipeline](https://github.com/karimtawfikk/echo/blob/main/src/hieroglyph_api/runtime.py): `src/hieroglyph_api/runtime.py`
- [Video API](https://github.com/karimtawfikk/echo/blob/main/src/video_generation_api/app.py): `src/video_generation_api/app.py`
- [Video pipeline](https://github.com/karimtawfikk/echo/blob/main/src/video_generation_api/runtime.py): `src/video_generation_api/runtime.py`

### Data and storage

- **PostgreSQL**
- **Cloudflare R2**

### Other components

- **Visitor**

## Connections

- Visitor → Explore home: browses (evidence: `README.md`)
- Explore home → Image upload: opens (evidence: `frontend/app/page.tsx`)
- Image upload → FastAPI gateway: submits image (evidence: `README.md`)
- FastAPI gateway → Recognition route: routes (evidence: `src/app/main.py`)
- Recognition route → Recognition API: forwards request (evidence: `README.md`)
- Recognition API → Recognition pipeline: runs inference (evidence: `src/recognition_api/app.py`)
- Recognition API → Recognition results: returns recognition (evidence: `README.md`)
- Recognition results → Historical chat: starts conversation (evidence: `README.md`)
- Historical chat → FastAPI gateway: sends prompt (evidence: `README.md`)
- FastAPI gateway → Chat route: routes (evidence: `src/app/main.py`)
- Chat route → Chatbot API: forwards request (evidence: `README.md`)
- Chatbot API → Chat service: dispatches (evidence: `src/chatbot_api/app.py`)
- Chat service → RAG and voice runtime: calls (evidence: `src/chatbot_api/service.py`)
- RAG and voice runtime → PostgreSQL: queries context (evidence: `README.md`)
- Visitor → Translation UI: uploads inscription (evidence: `README.md`)
- Translation UI → FastAPI gateway: requests translation (evidence: `README.md`)
- FastAPI gateway → Hieroglyph route: routes (evidence: `src/app/main.py`)
- Hieroglyph route → Hieroglyph API: forwards request (evidence: `README.md`)
- Hieroglyph API → Detection service: dispatches (evidence: `src/hieroglyph_api/app.py`)
- Detection service → Detection pipeline: runs pipeline (evidence: `src/hieroglyph_api/service.py`)
- Visitor → Video UI: requests video (evidence: `README.md`)
- Video UI → FastAPI gateway: requests generation (evidence: `README.md`)
- FastAPI gateway → Video route: routes (evidence: `src/app/main.py`)
- Video route → Video API: forwards request (evidence: `README.md`)
- Video API → Video pipeline: dispatches (evidence: `src/video_generation_api/app.py`)
- Video pipeline → PostgreSQL: retrieves media metadata (evidence: `README.md`)
- Video pipeline → Cloudflare R2: fetches images (evidence: `README.md`)
- Explore home → Page shell: renders (evidence: `frontend/app/page.tsx`)
- Historical chat → Recognition client: loads session result (evidence: `frontend/app/chat/page.tsx`)
- Page shell → Language context: uses translations (evidence: `frontend/components/layout/PageShell.tsx`)
- Recognition client → Recognition results: provides result data (evidence: `frontend/lib/services/recognition.ts`)
