# marat-kabirov/bita-technical-test architecture

> Architecture diagram of the GitHub repository marat-kabirov/bita-technical-test, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/marat-kabirov/bita-technical-test
- Repository: https://github.com/marat-kabirov/bita-technical-test

## Overview

BITA is a FastAPI index-constituents service. Clients upload CSVs, which are validated and appended with upload provenance; clients can soft-delete an ingested row or export the latest surviving version per business key over an effective-date range, optionally reconstructed as of a past time. JSON exports are returned as records and CSV exports are streamed. The README documents these capabilities; the graph reflects sampled runtime code and omits uncertain implementation details.

Main entry points: [`app/main.py`](https://github.com/marat-kabirov/bita-technical-test/blob/main/app/main.py) (FastAPI routes), [`app/services/ingest.py`](https://github.com/marat-kabirov/bita-technical-test/blob/main/app/services/ingest.py) (CSV validation), [`app/services/query.py`](https://github.com/marat-kabirov/bita-technical-test/blob/main/app/services/query.py) (Current-version query), [`app/models.py`](https://github.com/marat-kabirov/bita-technical-test/blob/main/app/models.py) (Persistence models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_main["FastAPI routes<br/>[main.py]"]
  node_schemas["API schemas<br/>[schemas.py]"]
end

subgraph group_ingestion["CSV Ingestion"]
  node_ingest["CSV validation<br/>[ingest.py]"]
end

subgraph group_data["Query and Persistence"]
  node_query["Current-version query<br/>[query.py]"]
  node_db["Session and engine<br/>[db.py]"]
  node_models["Persistence models<br/>[models.py]"]
end

node_client(("API client"))
node_csvfile["CSV upload"]
node_postgres[("PostgreSQL")]

node_client -->|"HTTP requests"| node_main
node_csvfile -->|"uploaded file"| node_main
node_main -->|"ingests CSV"| node_ingest
node_ingest -->|"inserts upload and rows"| node_postgres
node_main -->|"soft-deletes record"| node_postgres
node_main -->|"requests export rows"| node_query
node_query -->|"queries versions"| node_postgres
node_main -->|"validates and shapes output"| node_schemas
node_db -->|"connects"| node_postgres
node_main -->|"creates tables and sessions"| node_db
node_ingest -->|"uses upload models"| node_models
node_query -->|"queries constituent model"| node_models
node_main -->|"loads constituent record"| node_models

click node_main "https://github.com/marat-kabirov/bita-technical-test/blob/main/app/main.py"
click node_schemas "https://github.com/marat-kabirov/bita-technical-test/blob/main/app/schemas.py"
click node_ingest "https://github.com/marat-kabirov/bita-technical-test/blob/main/app/services/ingest.py"
click node_query "https://github.com/marat-kabirov/bita-technical-test/blob/main/app/services/query.py"
click node_db "https://github.com/marat-kabirov/bita-technical-test/blob/main/app/db.py"
click node_models "https://github.com/marat-kabirov/bita-technical-test/blob/main/app/models.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_main,node_schemas,node_client toneBlue
class node_ingest,node_postgres toneAmber
class node_query,node_db,node_models toneMint
class node_csvfile toneIndigo
```

## Components

### HTTP API

- [FastAPI routes](https://github.com/marat-kabirov/bita-technical-test/blob/main/app/main.py): `app/main.py`
- [API schemas](https://github.com/marat-kabirov/bita-technical-test/blob/main/app/schemas.py): `app/schemas.py`

### CSV Ingestion

- [CSV validation](https://github.com/marat-kabirov/bita-technical-test/blob/main/app/services/ingest.py): `app/services/ingest.py`

### Query and Persistence

- [Current-version query](https://github.com/marat-kabirov/bita-technical-test/blob/main/app/services/query.py): `app/services/query.py`
- [Session and engine](https://github.com/marat-kabirov/bita-technical-test/blob/main/app/db.py): `app/db.py`
- [Persistence models](https://github.com/marat-kabirov/bita-technical-test/blob/main/app/models.py): `app/models.py`

### Other components

- **API client**
- **CSV upload**
- **PostgreSQL**

## Connections

- API client → FastAPI routes: HTTP requests
- CSV upload → FastAPI routes: uploaded file
- FastAPI routes → CSV validation: ingests CSV
- CSV validation → PostgreSQL: inserts upload and rows
- FastAPI routes → PostgreSQL: soft-deletes record
- FastAPI routes → Current-version query: requests export rows
- Current-version query → PostgreSQL: queries versions
- FastAPI routes → API schemas: validates and shapes output
- Session and engine → PostgreSQL: connects
- FastAPI routes → Session and engine: creates tables and sessions
- CSV validation → Persistence models: uses upload models
- Current-version query → Persistence models: queries constituent model
- FastAPI routes → Persistence models: loads constituent record
