# rcbtst/files-stats-service-test-app architecture

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

- Interactive diagram: https://gitdiagram.com/rcbtst/files-stats-service-test-app
- Repository: https://github.com/rcbtst/files-stats-service-test-app

## Overview

This is a FastAPI web application for discovering and downloading files from an external API, persisting their contents and digit counts, and presenting download status, files, and statistics. The main workflow starts through the downloads route: it creates a download record and schedules a background task, which retrieves files in batches, computes statistics, and updates local and remote downloaded markers. Separate routes render paginated file and statistics views. The graph follows documented and indexed references; unsampled templates and page routes are represented at their tree paths.

Main entry points: [`src/database/crud.py`](https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/database/crud.py) (Database operations), [`src/web_app/routes/__init__.py`](https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/web_app/routes/__init__.py) (Route setup), [`src/web_app/routes/downloads.py`](https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/web_app/routes/downloads.py) (Download routes), [`src/web_app/routes/files.py`](https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/web_app/routes/files.py) (Files route)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_app["FastAPI app<br/>[__init__.py]"]
  node_route_setup["Route setup<br/>[__init__.py]"]
  node_download_route["Download routes<br/>[downloads.py]"]
  node_files_route["Files route<br/>[files.py]"]
  node_stats_route["Statistics route<br/>[stats.py]"]
  node_index_route["Index route<br/>[index.py]"]
  node_query_models["Query models"]
  node_page_templates["HTML templates"]
end

subgraph group_processing["Download processing"]
  node_download_task["Download task<br/>[downloads.py]"]
  node_digit_stats["Digit statistics<br/>[stats.py]"]
end

subgraph group_persistence["Persistence"]
  node_db_crud["Database operations<br/>[crud.py]"]
  node_db_schema["Data schema<br/>[schema.py]"]
  node_sqlite[("SQLite database")]
end

subgraph group_integration["External integration"]
  node_files_client["Files API client"]
  node_config["Runtime settings<br/>[config.py]"]
end

node_user(("Browser user"))
node_files_service{{"External files API"}}

node_user -->|"starts downloads"| node_download_route
node_user -->|"views files"| node_files_route
node_user -->|"views statistics"| node_stats_route
node_user -.->|"opens page"| node_index_route
node_app -->|"sets up routes"| node_route_setup
node_app -->|"starts task"| node_download_task
node_route_setup -->|"registers route"| node_download_route
node_route_setup -->|"registers route"| node_files_route
node_route_setup -->|"registers route"| node_stats_route
node_route_setup -->|"registers route"| node_index_route
node_download_route -->|"creates and reads"| node_db_crud
node_download_route -->|"schedules task"| node_download_task
node_files_route -->|"reads files"| node_db_crud
node_files_route -->|"validates query"| node_query_models
node_stats_route -->|"reads statistics"| node_db_crud
node_stats_route -->|"validates query"| node_query_models
node_download_route -->|"renders status"| node_page_templates
node_files_route -->|"renders files"| node_page_templates
node_stats_route -->|"renders statistics"| node_page_templates
node_index_route -->|"renders page"| node_page_templates
node_download_task -->|"reads and updates"| node_db_crud
node_download_task -->|"fetches and marks files"| node_files_client
node_download_task -->|"calculates counts"| node_digit_stats
node_files_client -->|"sends API requests"| node_files_service
node_db_crud -->|"queries models"| node_db_schema
node_db_crud -->|"reads and writes"| node_sqlite
node_db_schema -.->|"defines tables"| node_sqlite
node_files_client -->|"uses settings"| node_config
node_db_crud -.->|"database setup"| node_config

click node_app "https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/web_app/__init__.py"
click node_route_setup "https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/web_app/routes/__init__.py"
click node_download_route "https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/web_app/routes/downloads.py"
click node_files_route "https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/web_app/routes/files.py"
click node_stats_route "https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/web_app/routes/stats.py"
click node_index_route "https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/web_app/routes/index.py"
click node_query_models "https://github.com/rcbtst/files-stats-service-test-app/tree/main/src/web_app/models"
click node_page_templates "https://github.com/rcbtst/files-stats-service-test-app/tree/main/src/web_app/templates"
click node_download_task "https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/web_app/tasks/downloads.py"
click node_digit_stats "https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/utils/stats.py"
click node_files_client "https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/external_apis/files_api_client.py"
click node_db_crud "https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/database/crud.py"
click node_db_schema "https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/database/schema.py"
click node_config "https://github.com/rcbtst/files-stats-service-test-app/blob/main/config.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_app,node_route_setup,node_download_route,node_files_route,node_stats_route,node_index_route,node_query_models,node_page_templates,node_user toneBlue
class node_download_task,node_digit_stats toneAmber
class node_db_crud,node_db_schema,node_sqlite,node_files_service toneMint
class node_files_client,node_config toneRose
```

## Components

### Web interface

- [FastAPI app](https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/web_app/__init__.py): `src/web_app/__init__.py`
- [Route setup](https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/web_app/routes/__init__.py): `src/web_app/routes/__init__.py`
- [Download routes](https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/web_app/routes/downloads.py): `src/web_app/routes/downloads.py`
- [Files route](https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/web_app/routes/files.py): `src/web_app/routes/files.py`
- [Statistics route](https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/web_app/routes/stats.py): `src/web_app/routes/stats.py`
- [Index route](https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/web_app/routes/index.py): `src/web_app/routes/index.py`
- [Query models](https://github.com/rcbtst/files-stats-service-test-app/tree/main/src/web_app/models): `src/web_app/models`
- [HTML templates](https://github.com/rcbtst/files-stats-service-test-app/tree/main/src/web_app/templates): `src/web_app/templates`

### Download processing

- [Download task](https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/web_app/tasks/downloads.py): `src/web_app/tasks/downloads.py`
- [Digit statistics](https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/utils/stats.py): `src/utils/stats.py`

### Persistence

- [Database operations](https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/database/crud.py): `src/database/crud.py`
- [Data schema](https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/database/schema.py): `src/database/schema.py`
- **SQLite database**

### External integration

- [Files API client](https://github.com/rcbtst/files-stats-service-test-app/blob/main/src/external_apis/files_api_client.py): `src/external_apis/files_api_client.py`
- [Runtime settings](https://github.com/rcbtst/files-stats-service-test-app/blob/main/config.py): `config.py`

### Other components

- **Browser user**
- **External files API**

## Connections

- Browser user → Download routes: starts downloads (evidence: `src/web_app/routes/downloads.py`)
- Browser user → Files route: views files (evidence: `src/web_app/routes/files.py`)
- Browser user → Statistics route: views statistics (evidence: `src/web_app/routes/stats.py`)
- Browser user → Index route: opens page
- FastAPI app → Route setup: sets up routes (evidence: `src/web_app/__init__.py`)
- FastAPI app → Download task: starts task (evidence: `src/web_app/__init__.py`)
- Route setup → Download routes: registers route (evidence: `src/web_app/routes/__init__.py`)
- Route setup → Files route: registers route (evidence: `src/web_app/routes/__init__.py`)
- Route setup → Statistics route: registers route (evidence: `src/web_app/routes/__init__.py`)
- Route setup → Index route: registers route (evidence: `src/web_app/routes/__init__.py`)
- Download routes → Database operations: creates and reads (evidence: `src/web_app/routes/downloads.py`)
- Download routes → Download task: schedules task (evidence: `src/web_app/routes/downloads.py`)
- Files route → Database operations: reads files (evidence: `src/web_app/routes/files.py`)
- Files route → Query models: validates query (evidence: `src/web_app/routes/files.py`)
- Statistics route → Database operations: reads statistics (evidence: `src/web_app/routes/stats.py`)
- Statistics route → Query models: validates query (evidence: `src/web_app/routes/stats.py`)
- Download routes → HTML templates: renders status (evidence: `src/web_app/routes/downloads.py`)
- Files route → HTML templates: renders files (evidence: `src/web_app/routes/files.py`)
- Statistics route → HTML templates: renders statistics (evidence: `src/web_app/routes/stats.py`)
- Index route → HTML templates: renders page (evidence: `src/web_app/routes/index.py`)
- Download task → Database operations: reads and updates (evidence: `src/web_app/tasks/downloads.py`)
- Download task → Files API client: fetches and marks files (evidence: `src/web_app/tasks/downloads.py`)
- Download task → Digit statistics: calculates counts (evidence: `src/web_app/tasks/downloads.py`)
- Files API client → External files API: sends API requests (evidence: `src/external_apis/files_api_client.py`)
- Database operations → Data schema: queries models (evidence: `src/database/crud.py`)
- Database operations → SQLite database: reads and writes (evidence: `src/database/crud.py`)
- Data schema → SQLite database: defines tables
- Files API client → Runtime settings: uses settings (evidence: `src/external_apis/files_api_client.py`)
- Database operations → Runtime settings: database setup
