# ancientnerds/ancientmap architecture

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

- Interactive diagram: https://gitdiagram.com/ancientnerds/ancientmap
- Repository: https://github.com/ancientnerds/ancientmap

## Overview

Ancient Nerds is a research platform that combines archaeological records from many sources, serves them through a spatial API, and presents them on an interactive globe. The central workflow is source ingestion and normalization into PostgreSQL/PostGIS, then API delivery to the frontend for map exploration. Separate product branches provide Lyra research assistance, automated news and radar discovery, and a card game. The README documents the broad system flow; available source excerpts are incomplete, so edges are limited to documented relationships and clear excerpted calls.

Main entry points: [`api/cardgame/routes.py`](https://github.com/ancientnerds/ancientmap/blob/main/api/cardgame/routes.py) (Card game API), [`api/main.py`](https://github.com/ancientnerds/ancientmap/blob/main/api/main.py) (REST API), [`pipeline/database.py`](https://github.com/ancientnerds/ancientmap/blob/main/pipeline/database.py) (Unified spatial data), [`api/routes/public_v1.py`](https://github.com/ancientnerds/ancientmap/blob/main/api/routes/public_v1.py) (Public API v1)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Data ingestion"]
  node_ingest_cli["Ingestion runner<br/>[main.py]"]
  node_connectors["Source ingesters"]
  node_normalize["Normalize records"]
end

subgraph group_core["Platform services"]
  node_db_models[("Unified spatial data<br/>[database.py]")]
  node_public_scope["Public site scope<br/>[public_sites.py]"]
  node_api["REST API<br/>[main.py]"]
  node_public_api["Public API v1<br/>[public_v1.py]"]
  node_api_cache["API caching<br/>[cache.py]"]
  node_auth["Authentication<br/>[auth.py]"]
end

subgraph group_explore["Globe experience"]
  node_frontend["Research web app<br/>[App.tsx]"]
  node_globe["Interactive 3D globe<br/>[Globe.tsx]"]
  node_offline["Offline map support<br/>[OfflineStorage.ts]"]
end

subgraph group_research["Research discovery"]
  node_lyra_tools["Lyra research tools<br/>[lyra_tools.py]"]
  node_lyra_worker["Theo research worker<br/>[theo_worker.py]"]
  node_research_graph[("Knowledge graph<br/>[research_graph.py]")]
  node_graph_ingest["Graph ingestion"]
  node_prospector["Radar proposals<br/>[pipeline.py]"]
  node_pipeline_status["Pipeline status view"]
end

subgraph group_community["Community features"]
  node_cards_api["Card game API<br/>[routes.py]"]
  node_card_models[("Card game models<br/>[models.py]")]
  node_achievements["Card achievements<br/>[achievements.py]"]
  node_packs["Card packs<br/>[packs.py]"]
end

node_researcher(("Researcher"))
node_sources[("Open data sources")]

node_sources -->|"supplies data"| node_connectors
node_ingest_cli -->|"runs ingesters"| node_connectors
node_connectors -->|"ingests records"| node_normalize
node_normalize -->|"stores records"| node_db_models
node_db_models -->|"serves data"| node_api
node_api -->|"mounts routes"| node_public_api
node_public_api -->|"queries sites"| node_db_models
node_public_api -->|"filters sites"| node_public_scope
node_api -->|"uses cache"| node_api_cache
node_researcher -->|"explores"| node_frontend
node_frontend -->|"renders map"| node_globe
node_globe -->|"requests site data"| node_api
node_frontend -.->|"supports offline use"| node_offline
node_researcher -->|"asks research questions"| node_lyra_tools
node_lyra_worker -.->|"runs research tools"| node_lyra_tools
node_lyra_worker -->|"builds research graph"| node_research_graph
node_graph_ingest -->|"writes graph data"| node_research_graph
node_prospector -->|"writes proposals"| node_db_models
node_pipeline_status -.->|"reports pipeline status"| node_researcher
node_researcher -->|"plays card game"| node_cards_api
node_cards_api -->|"reads card data"| node_card_models
node_cards_api -->|"opens packs"| node_packs
node_cards_api -->|"checks achievements"| node_achievements

click node_ingest_cli "https://github.com/ancientnerds/ancientmap/blob/main/pipeline/main.py"
click node_connectors "https://github.com/ancientnerds/ancientmap/tree/main/pipeline/ingesters"
click node_normalize "https://github.com/ancientnerds/ancientmap/tree/main/pipeline/normalizers"
click node_db_models "https://github.com/ancientnerds/ancientmap/blob/main/pipeline/database.py"
click node_public_scope "https://github.com/ancientnerds/ancientmap/blob/main/pipeline/utils/public_sites.py"
click node_api "https://github.com/ancientnerds/ancientmap/blob/main/api/main.py"
click node_public_api "https://github.com/ancientnerds/ancientmap/blob/main/api/routes/public_v1.py"
click node_api_cache "https://github.com/ancientnerds/ancientmap/blob/main/api/cache.py"
click node_auth "https://github.com/ancientnerds/ancientmap/blob/main/api/routes/auth.py"
click node_frontend "https://github.com/ancientnerds/ancientmap/blob/main/ancient-nerds-map/src/App.tsx"
click node_globe "https://github.com/ancientnerds/ancientmap/blob/main/ancient-nerds-map/src/components/Globe.tsx"
click node_offline "https://github.com/ancientnerds/ancientmap/blob/main/ancient-nerds-map/src/services/OfflineStorage.ts"
click node_lyra_tools "https://github.com/ancientnerds/ancientmap/blob/main/api/services/lyra_tools.py"
click node_lyra_worker "https://github.com/ancientnerds/ancientmap/blob/main/api/services/theo_worker.py"
click node_research_graph "https://github.com/ancientnerds/ancientmap/blob/main/pipeline/lyra/research_graph.py"
click node_graph_ingest "https://github.com/ancientnerds/ancientmap/blob/main/pipeline/lyra/graph_full_ingest.py"
click node_prospector "https://github.com/ancientnerds/ancientmap/blob/main/pipeline/lyra/prospector/pipeline.py"
click node_pipeline_status "https://github.com/ancientnerds/ancientmap/blob/main/ancient-nerds-map/src/components/nerv/usePipelineStatus.ts"
click node_cards_api "https://github.com/ancientnerds/ancientmap/blob/main/api/cardgame/routes.py"
click node_card_models "https://github.com/ancientnerds/ancientmap/blob/main/api/cardgame/models.py"
click node_achievements "https://github.com/ancientnerds/ancientmap/blob/main/api/cardgame/achievements.py"
click node_packs "https://github.com/ancientnerds/ancientmap/blob/main/api/cardgame/packs.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_ingest_cli,node_connectors,node_normalize toneBlue
class node_db_models,node_public_scope,node_api,node_public_api,node_api_cache,node_auth,node_sources toneAmber
class node_frontend,node_globe,node_offline toneMint
class node_lyra_tools,node_lyra_worker,node_research_graph,node_graph_ingest,node_prospector,node_pipeline_status toneRose
class node_cards_api,node_card_models,node_achievements,node_packs,node_researcher toneIndigo
```

## Components

### Data ingestion

- [Ingestion runner](https://github.com/ancientnerds/ancientmap/blob/main/pipeline/main.py): `pipeline/main.py`
- [Source ingesters](https://github.com/ancientnerds/ancientmap/tree/main/pipeline/ingesters): `pipeline/ingesters`
- [Normalize records](https://github.com/ancientnerds/ancientmap/tree/main/pipeline/normalizers): `pipeline/normalizers`

### Platform services

- [Unified spatial data](https://github.com/ancientnerds/ancientmap/blob/main/pipeline/database.py): `pipeline/database.py`
- [Public site scope](https://github.com/ancientnerds/ancientmap/blob/main/pipeline/utils/public_sites.py): `pipeline/utils/public_sites.py`
- [REST API](https://github.com/ancientnerds/ancientmap/blob/main/api/main.py): `api/main.py`
- [Public API v1](https://github.com/ancientnerds/ancientmap/blob/main/api/routes/public_v1.py): `api/routes/public_v1.py`
- [API caching](https://github.com/ancientnerds/ancientmap/blob/main/api/cache.py): `api/cache.py`
- [Authentication](https://github.com/ancientnerds/ancientmap/blob/main/api/routes/auth.py): `api/routes/auth.py`

### Globe experience

- [Research web app](https://github.com/ancientnerds/ancientmap/blob/main/ancient-nerds-map/src/App.tsx): `ancient-nerds-map/src/App.tsx`
- [Interactive 3D globe](https://github.com/ancientnerds/ancientmap/blob/main/ancient-nerds-map/src/components/Globe.tsx): `ancient-nerds-map/src/components/Globe.tsx`
- [Offline map support](https://github.com/ancientnerds/ancientmap/blob/main/ancient-nerds-map/src/services/OfflineStorage.ts): `ancient-nerds-map/src/services/OfflineStorage.ts`

### Research discovery

- [Lyra research tools](https://github.com/ancientnerds/ancientmap/blob/main/api/services/lyra_tools.py): `api/services/lyra_tools.py`
- [Theo research worker](https://github.com/ancientnerds/ancientmap/blob/main/api/services/theo_worker.py): `api/services/theo_worker.py`
- [Knowledge graph](https://github.com/ancientnerds/ancientmap/blob/main/pipeline/lyra/research_graph.py): `pipeline/lyra/research_graph.py`
- [Graph ingestion](https://github.com/ancientnerds/ancientmap/blob/main/pipeline/lyra/graph_full_ingest.py): `pipeline/lyra/graph_full_ingest.py`
- [Radar proposals](https://github.com/ancientnerds/ancientmap/blob/main/pipeline/lyra/prospector/pipeline.py): `pipeline/lyra/prospector/pipeline.py`
- [Pipeline status view](https://github.com/ancientnerds/ancientmap/blob/main/ancient-nerds-map/src/components/nerv/usePipelineStatus.ts): `ancient-nerds-map/src/components/nerv/usePipelineStatus.ts`

### Community features

- [Card game API](https://github.com/ancientnerds/ancientmap/blob/main/api/cardgame/routes.py): `api/cardgame/routes.py`
- [Card game models](https://github.com/ancientnerds/ancientmap/blob/main/api/cardgame/models.py): `api/cardgame/models.py`
- [Card achievements](https://github.com/ancientnerds/ancientmap/blob/main/api/cardgame/achievements.py): `api/cardgame/achievements.py`
- [Card packs](https://github.com/ancientnerds/ancientmap/blob/main/api/cardgame/packs.py): `api/cardgame/packs.py`

### Other components

- **Researcher**
- **Open data sources**

## Connections

- Open data sources → Source ingesters: supplies data (evidence: `README.md`)
- Ingestion runner → Source ingesters: runs ingesters (evidence: `pipeline/main.py`)
- Source ingesters → Normalize records: ingests records (evidence: `README.md`)
- Normalize records → Unified spatial data: stores records (evidence: `README.md`)
- Unified spatial data → REST API: serves data (evidence: `README.md`)
- REST API → Public API v1: mounts routes (evidence: `api/main.py`)
- Public API v1 → Unified spatial data: queries sites (evidence: `api/routes/public_v1.py`)
- Public API v1 → Public site scope: filters sites (evidence: `api/routes/public_v1.py`)
- REST API → API caching: uses cache (evidence: `api/main.py`)
- Researcher → Research web app: explores (evidence: `README.md`)
- Research web app → Interactive 3D globe: renders map (evidence: `README.md`)
- Interactive 3D globe → REST API: requests site data (evidence: `README.md`)
- Research web app → Offline map support: supports offline use
- Researcher → Lyra research tools: asks research questions (evidence: `README.md`)
- Theo research worker → Lyra research tools: runs research tools
- Theo research worker → Knowledge graph: builds research graph (evidence: `api/services/theo_worker.py`)
- Graph ingestion → Knowledge graph: writes graph data (evidence: `pipeline/lyra/graph_full_ingest.py`)
- Radar proposals → Unified spatial data: writes proposals (evidence: `pipeline/lyra/prospector/pipeline.py`)
- Pipeline status view → Researcher: reports pipeline status
- Researcher → Card game API: plays card game (evidence: `README.md`)
- Card game API → Card game models: reads card data (evidence: `api/cardgame/routes.py`)
- Card game API → Card packs: opens packs (evidence: `api/cardgame/routes.py`)
- Card game API → Card achievements: checks achievements (evidence: `api/cardgame/routes.py`)
