# sirfilips/centmeta-backend architecture

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

- Interactive diagram: https://gitdiagram.com/sirfilips/centmeta-backend
- Repository: https://github.com/sirfilips/centmeta-backend

## Overview

CentMeta is a backend for Centurion Commander metagame analysis. The primary workflow is decklist acquisition from Moxfield, storage in SQLite, statistical aggregation, and REST API responses to the frontend, enriched with Scryfall card metadata. The README also documents caching, automated database refresh and cache warming, and an optional community-voting feature. The implementation is concentrated in two large Python files; unsampled capabilities are represented at the documented subsystem level, without assuming their internal call structure.

Main entry points: [`main.py`](https://github.com/sirfilips/centmeta-backend/blob/main/main.py) (REST API), [`master_scraper.py`](https://github.com/sirfilips/centmeta-backend/blob/main/master_scraper.py) (Deck scraper)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Deck ingestion"]
  node_scraper["Deck scraper<br/>[master_scraper.py]"]
end

subgraph group_analytics["API and analytics"]
  node_api["REST API<br/>[main.py]"]
  node_stats["Metagame statistics<br/>[main.py]"]
  node_cache["Response caches<br/>[main.py]"]
  node_database[("SQLite database<br/>[main.py]")]
  node_maintenance["Refresh and prewarm<br/>[main.py]"]
  node_admin["Deck administration<br/>[main.py]"]
end

subgraph group_enrichment["Metadata and community"]
  node_card_metadata["Card metadata resolution<br/>[main.py]"]
  node_community["Community Observatory<br/>[main.py]"]
end

node_frontend(("Frontend"))
node_moxfield{{"Moxfield"}}
node_scryfall{{"Scryfall API"}}

node_frontend -->|"requests"| node_api
node_api -->|"dispatches"| node_stats
node_stats -->|"queries"| node_database
node_stats -->|"resolves cards"| node_card_metadata
node_api -->|"uses"| node_cache
node_maintenance -->|"refreshes"| node_database
node_maintenance -->|"warms"| node_cache
node_scraper -->|"fetches decks"| node_moxfield
node_scraper -->|"writes decks"| node_database
node_api -->|"pings via limiter"| node_scraper
node_card_metadata -->|"fetches metadata"| node_scryfall
node_api -->|"serves voting"| node_community
node_api -->|"routes admin actions"| node_admin
node_admin -->|"removes decks"| node_database

click node_api "https://github.com/sirfilips/centmeta-backend/blob/main/main.py"
click node_stats "https://github.com/sirfilips/centmeta-backend/blob/main/main.py"
click node_cache "https://github.com/sirfilips/centmeta-backend/blob/main/main.py"
click node_database "https://github.com/sirfilips/centmeta-backend/blob/main/main.py"
click node_maintenance "https://github.com/sirfilips/centmeta-backend/blob/main/main.py"
click node_scraper "https://github.com/sirfilips/centmeta-backend/blob/main/master_scraper.py"
click node_card_metadata "https://github.com/sirfilips/centmeta-backend/blob/main/main.py"
click node_community "https://github.com/sirfilips/centmeta-backend/blob/main/main.py"
click node_admin "https://github.com/sirfilips/centmeta-backend/blob/main/main.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_scraper,node_frontend toneBlue
class node_api,node_stats,node_cache,node_database,node_maintenance,node_admin toneAmber
class node_card_metadata,node_community,node_scryfall toneMint
class node_moxfield toneIndigo
```

## Components

### Deck ingestion

- [Deck scraper](https://github.com/sirfilips/centmeta-backend/blob/main/master_scraper.py): `master_scraper.py`

### API and analytics

- [REST API](https://github.com/sirfilips/centmeta-backend/blob/main/main.py): `main.py`
- [Metagame statistics](https://github.com/sirfilips/centmeta-backend/blob/main/main.py): `main.py`
- [Response caches](https://github.com/sirfilips/centmeta-backend/blob/main/main.py): `main.py`
- [SQLite database](https://github.com/sirfilips/centmeta-backend/blob/main/main.py): `main.py`
- [Refresh and prewarm](https://github.com/sirfilips/centmeta-backend/blob/main/main.py): `main.py`
- [Deck administration](https://github.com/sirfilips/centmeta-backend/blob/main/main.py): `main.py`

### Metadata and community

- [Card metadata resolution](https://github.com/sirfilips/centmeta-backend/blob/main/main.py): `main.py`
- [Community Observatory](https://github.com/sirfilips/centmeta-backend/blob/main/main.py): `main.py`

### Other components

- **Frontend**
- **Moxfield**
- **Scryfall API**

## Connections

- Frontend → REST API: requests (evidence: `README.md`)
- REST API → Metagame statistics: dispatches (evidence: `main.py`)
- Metagame statistics → SQLite database: queries (evidence: `README.md`)
- Metagame statistics → Card metadata resolution: resolves cards (evidence: `main.py`)
- REST API → Response caches: uses (evidence: `README.md`)
- Refresh and prewarm → SQLite database: refreshes (evidence: `README.md`)
- Refresh and prewarm → Response caches: warms (evidence: `README.md`)
- Deck scraper → Moxfield: fetches decks (evidence: `master_scraper.py`)
- Deck scraper → SQLite database: writes decks (evidence: `README.md`)
- REST API → Deck scraper: pings via limiter (evidence: `main.py`)
- Card metadata resolution → Scryfall API: fetches metadata (evidence: `README.md`)
- REST API → Community Observatory: serves voting (evidence: `README.md`)
- REST API → Deck administration: routes admin actions (evidence: `main.py`)
- Deck administration → SQLite database: removes decks (evidence: `README.md`)
