# pakvakunchik/api_downloader architecture

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

- Interactive diagram: https://gitdiagram.com/pakvakunchik/api_downloader
- Repository: https://github.com/pakvakunchik/api_downloader

## Overview

API Downloader exposes pages for starting downloads and viewing files, plus an endpoint for digit-frequency statistics. The main download flow fetches names from an external service, requests ZIP batches, stores their contents, and reports downloaded batches back. File listing and calculations query the same database. The graph reflects the shown router and utility calls; the README is empty, and no unsampled capabilities are assumed.

Main entry points: [`app/routers.py`](https://github.com/pakvakunchik/api_downloader/blob/main/app/routers.py) (API routes), [`app/utils.py`](https://github.com/pakvakunchik/api_downloader/blob/main/app/utils.py) (Download utilities), [`app/models.py`](https://github.com/pakvakunchik/api_downloader/blob/main/app/models.py) (File and progress models), [`app/database.py`](https://github.com/pakvakunchik/api_downloader/blob/main/app/database.py) (Database sessions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and pages"]
  node_app["FastAPI application<br/>[main.py]"]
  node_routes["API routes<br/>[routers.py]"]
  node_download_page["Download page<br/>[download.html]"]
  node_files_page["Files page<br/>[files_page.html]"]
  node_schemas["API schemas<br/>[schemas.py]"]
end

subgraph group_download["Download integration"]
  node_download_utils["Download utilities<br/>[utils.py]"]
  node_remote_service["File service"]
end

subgraph group_data["Persistence and domain"]
  node_database_config["Database sessions<br/>[database.py]"]
  node_file_models["File and progress models<br/>[models.py]"]
  node_status_enum["Progress status<br/>[models_enum.py]"]
  node_file_repository["File repository helper<br/>[repository.py]"]
  node_file_store[("PostgreSQL database")]
end

node_user(("User"))

node_user -->|"sends requests"| node_app
node_app -->|"registers routes"| node_routes
node_user -->|"requests pages"| node_routes
node_routes -->|"serves page"| node_download_page
node_routes -->|"serves page"| node_files_page
node_routes -->|"calls download"| node_download_utils
node_download_utils -->|"fetches names"| node_remote_service
node_download_utils -->|"requests ZIP batches"| node_remote_service
node_download_utils -->|"marks downloaded"| node_remote_service
node_download_utils -->|"opens sessions"| node_database_config
node_download_utils -->|"inserts files"| node_file_models
node_routes -->|"depends on sessions"| node_database_config
node_routes -->|"queries files"| node_file_models
node_database_config -->|"connects"| node_file_store
node_file_models -->|"uses base"| node_database_config
node_file_models -->|"uses status"| node_status_enum
node_file_repository -->|"queries and constructs"| node_file_models
node_routes -->|"uses request and response models"| node_schemas

click node_app "https://github.com/pakvakunchik/api_downloader/blob/main/main.py"
click node_routes "https://github.com/pakvakunchik/api_downloader/blob/main/app/routers.py"
click node_download_page "https://github.com/pakvakunchik/api_downloader/blob/main/templates/download.html"
click node_files_page "https://github.com/pakvakunchik/api_downloader/blob/main/templates/files_page.html"
click node_schemas "https://github.com/pakvakunchik/api_downloader/blob/main/app/schemas.py"
click node_download_utils "https://github.com/pakvakunchik/api_downloader/blob/main/app/utils.py"
click node_database_config "https://github.com/pakvakunchik/api_downloader/blob/main/app/database.py"
click node_file_models "https://github.com/pakvakunchik/api_downloader/blob/main/app/models.py"
click node_status_enum "https://github.com/pakvakunchik/api_downloader/blob/main/app/models_enum.py"
click node_file_repository "https://github.com/pakvakunchik/api_downloader/blob/main/app/repository.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_routes,node_download_page,node_files_page,node_schemas,node_user toneBlue
class node_download_utils,node_remote_service toneAmber
class node_database_config,node_file_models,node_status_enum,node_file_repository,node_file_store toneMint
```

## Components

### API and pages

- [FastAPI application](https://github.com/pakvakunchik/api_downloader/blob/main/main.py): `main.py`
- [API routes](https://github.com/pakvakunchik/api_downloader/blob/main/app/routers.py): `app/routers.py`
- [Download page](https://github.com/pakvakunchik/api_downloader/blob/main/templates/download.html): `templates/download.html`
- [Files page](https://github.com/pakvakunchik/api_downloader/blob/main/templates/files_page.html): `templates/files_page.html`
- [API schemas](https://github.com/pakvakunchik/api_downloader/blob/main/app/schemas.py): `app/schemas.py`

### Download integration

- [Download utilities](https://github.com/pakvakunchik/api_downloader/blob/main/app/utils.py): `app/utils.py`
- **File service**

### Persistence and domain

- [Database sessions](https://github.com/pakvakunchik/api_downloader/blob/main/app/database.py): `app/database.py`
- [File and progress models](https://github.com/pakvakunchik/api_downloader/blob/main/app/models.py): `app/models.py`
- [Progress status](https://github.com/pakvakunchik/api_downloader/blob/main/app/models_enum.py): `app/models_enum.py`
- [File repository helper](https://github.com/pakvakunchik/api_downloader/blob/main/app/repository.py): `app/repository.py`
- **PostgreSQL database**

### Other components

- **User**

## Connections

- User → FastAPI application: sends requests
- FastAPI application → API routes: registers routes (evidence: `main.py`)
- User → API routes: requests pages
- API routes → Download page: serves page (evidence: `app/routers.py`)
- API routes → Files page: serves page (evidence: `app/routers.py`)
- API routes → Download utilities: calls download (evidence: `app/routers.py`)
- Download utilities → File service: fetches names (evidence: `app/utils.py`)
- Download utilities → File service: requests ZIP batches (evidence: `app/utils.py`)
- Download utilities → File service: marks downloaded (evidence: `app/utils.py`)
- Download utilities → Database sessions: opens sessions (evidence: `app/utils.py`)
- Download utilities → File and progress models: inserts files (evidence: `app/utils.py`)
- API routes → Database sessions: depends on sessions (evidence: `app/routers.py`)
- API routes → File and progress models: queries files (evidence: `app/routers.py`)
- Database sessions → PostgreSQL database: connects (evidence: `app/database.py`)
- File and progress models → Database sessions: uses base (evidence: `app/models.py`)
- File and progress models → Progress status: uses status (evidence: `app/models.py`)
- File repository helper → File and progress models: queries and constructs (evidence: `app/repository.py`)
- API routes → API schemas: uses request and response models (evidence: `app/routers.py`)
