# srtepa/cns_course_project architecture

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

- Interactive diagram: https://gitdiagram.com/srtepa/cns_course_project
- Repository: https://github.com/srtepa/cns_course_project

## Overview

This Flask application monitors NBRB currency rates, presents current and historical values with analytics, and provides conversion, account, favorites, and settings features. The main workflow is a browser request handled by the routes, which obtain rate data from the API client or JSON cache, optionally analyze history, and render a page. Authentication and preferences are separate supporting branches. The excerpts establish the main service calls and persistence behavior; template and client-side wiring is not fully shown, so those links are limited to documented or directly supported relationships.

Main entry points: [`controllers/main_routes.py`](https://github.com/srtepa/cns_course_project/blob/main/controllers/main_routes.py) (Flask routes), [`app.py`](https://github.com/srtepa/cns_course_project/blob/main/app.py) (Flask app setup), [`services/api_client.py`](https://github.com/srtepa/cns_course_project/blob/main/services/api_client.py) (NBRB API client), [`services/data_manager.py`](https://github.com/srtepa/cns_course_project/blob/main/services/data_manager.py) (Rate data manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_routes["Flask routes<br/>[main_routes.py]"]
  node_views["Page templates"]
  node_browser["Browser interface<br/>[app.js]"]
  node_config["App configuration<br/>[config.py]"]
  node_app["Flask app setup<br/>[app.py]"]
end

subgraph group_rates["Rate data"]
  node_api["NBRB API client<br/>[api_client.py]"]
  node_network["Retry and breaker<br/>[network.py]"]
  node_data_manager["Rate data manager<br/>[data_manager.py]"]
  node_rate_store[("Rate snapshots<br/>[rates.json]")]
  node_history_model["Rate history model<br/>[history.py]"]
end

subgraph group_accounts["Accounts and preferences"]
  node_auth["Authentication manager<br/>[auth_manager.py]"]
  node_user_store[("User records<br/>[users.json]")]
  node_settings_store[("User settings<br/>[settings.json]")]
end

subgraph group_analysis["Analysis and presentation"]
  node_currency_model["Currency model<br/>[currency.py]"]
  node_analytics["Rate analytics<br/>[analytics.py]"]
  node_formatting["Date formatting<br/>[formatting.py]"]
end

node_visitor(("Visitor"))
node_nbrb["NBRB rates API"]

node_visitor -->|"requests pages"| node_routes
node_routes -->|"fetches rates"| node_api
node_api -->|"requests rates"| node_nbrb
node_api -->|"uses retries"| node_network
node_routes -->|"loads snapshots"| node_data_manager
node_data_manager -->|"reads and writes"| node_rate_store
node_data_manager -->|"parses snapshots"| node_history_model
node_api -->|"creates snapshots"| node_history_model
node_routes -->|"authenticates users"| node_auth
node_auth -->|"reads and writes"| node_user_store
node_routes -->|"loads preferences"| node_settings_store
node_data_manager -->|"reads and writes"| node_settings_store
node_routes -->|"analyzes history"| node_analytics
node_routes -->|"builds currency rows"| node_currency_model
node_routes -->|"renders pages"| node_views
node_app -->|"registers routes"| node_routes
node_app -->|"configures storage"| node_data_manager
node_app -->|"configures client"| node_api
node_app -->|"configures accounts"| node_auth
node_app -->|"registers filter"| node_formatting
node_config -->|"provides settings"| node_app
node_browser -.->|"submits interactions"| node_routes

click node_routes "https://github.com/srtepa/cns_course_project/blob/main/controllers/main_routes.py"
click node_views "https://github.com/srtepa/cns_course_project/tree/main/templates"
click node_browser "https://github.com/srtepa/cns_course_project/blob/main/static/js/app.js"
click node_config "https://github.com/srtepa/cns_course_project/blob/main/config.py"
click node_app "https://github.com/srtepa/cns_course_project/blob/main/app.py"
click node_api "https://github.com/srtepa/cns_course_project/blob/main/services/api_client.py"
click node_network "https://github.com/srtepa/cns_course_project/blob/main/services/network.py"
click node_data_manager "https://github.com/srtepa/cns_course_project/blob/main/services/data_manager.py"
click node_rate_store "https://github.com/srtepa/cns_course_project/blob/main/data/rates.json"
click node_history_model "https://github.com/srtepa/cns_course_project/blob/main/models/history.py"
click node_auth "https://github.com/srtepa/cns_course_project/blob/main/services/auth_manager.py"
click node_user_store "https://github.com/srtepa/cns_course_project/blob/main/data/users.json"
click node_settings_store "https://github.com/srtepa/cns_course_project/blob/main/data/settings.json"
click node_currency_model "https://github.com/srtepa/cns_course_project/blob/main/models/currency.py"
click node_analytics "https://github.com/srtepa/cns_course_project/blob/main/services/analytics.py"
click node_formatting "https://github.com/srtepa/cns_course_project/blob/main/services/formatting.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_routes,node_views,node_browser,node_config,node_app toneBlue
class node_api,node_network,node_data_manager,node_rate_store,node_history_model toneAmber
class node_auth,node_user_store,node_settings_store,node_nbrb toneMint
class node_currency_model,node_analytics,node_formatting toneRose
class node_visitor toneIndigo
```

## Components

### Web application

- [Flask routes](https://github.com/srtepa/cns_course_project/blob/main/controllers/main_routes.py): `controllers/main_routes.py`
- [Page templates](https://github.com/srtepa/cns_course_project/tree/main/templates): `templates`
- [Browser interface](https://github.com/srtepa/cns_course_project/blob/main/static/js/app.js): `static/js/app.js`
- [App configuration](https://github.com/srtepa/cns_course_project/blob/main/config.py): `config.py`
- [Flask app setup](https://github.com/srtepa/cns_course_project/blob/main/app.py): `app.py`

### Rate data

- [NBRB API client](https://github.com/srtepa/cns_course_project/blob/main/services/api_client.py): `services/api_client.py`
- [Retry and breaker](https://github.com/srtepa/cns_course_project/blob/main/services/network.py): `services/network.py`
- [Rate data manager](https://github.com/srtepa/cns_course_project/blob/main/services/data_manager.py): `services/data_manager.py`
- [Rate snapshots](https://github.com/srtepa/cns_course_project/blob/main/data/rates.json): `data/rates.json`
- [Rate history model](https://github.com/srtepa/cns_course_project/blob/main/models/history.py): `models/history.py`

### Accounts and preferences

- [Authentication manager](https://github.com/srtepa/cns_course_project/blob/main/services/auth_manager.py): `services/auth_manager.py`
- [User records](https://github.com/srtepa/cns_course_project/blob/main/data/users.json): `data/users.json`
- [User settings](https://github.com/srtepa/cns_course_project/blob/main/data/settings.json): `data/settings.json`

### Analysis and presentation

- [Currency model](https://github.com/srtepa/cns_course_project/blob/main/models/currency.py): `models/currency.py`
- [Rate analytics](https://github.com/srtepa/cns_course_project/blob/main/services/analytics.py): `services/analytics.py`
- [Date formatting](https://github.com/srtepa/cns_course_project/blob/main/services/formatting.py): `services/formatting.py`

### Other components

- **Visitor**
- **NBRB rates API**

## Connections

- Visitor → Flask routes: requests pages (evidence: `README.md`)
- Flask routes → NBRB API client: fetches rates (evidence: `controllers/main_routes.py`)
- NBRB API client → NBRB rates API: requests rates (evidence: `README.md`)
- NBRB API client → Retry and breaker: uses retries (evidence: `services/api_client.py`)
- Flask routes → Rate data manager: loads snapshots (evidence: `controllers/main_routes.py`)
- Rate data manager → Rate snapshots: reads and writes (evidence: `services/data_manager.py`)
- Rate data manager → Rate history model: parses snapshots (evidence: `services/data_manager.py`)
- NBRB API client → Rate history model: creates snapshots (evidence: `services/api_client.py`)
- Flask routes → Authentication manager: authenticates users (evidence: `controllers/main_routes.py`)
- Authentication manager → User records: reads and writes (evidence: `services/auth_manager.py`)
- Flask routes → User settings: loads preferences (evidence: `controllers/main_routes.py`)
- Rate data manager → User settings: reads and writes (evidence: `services/data_manager.py`)
- Flask routes → Rate analytics: analyzes history (evidence: `controllers/main_routes.py`)
- Flask routes → Currency model: builds currency rows (evidence: `controllers/main_routes.py`)
- Flask routes → Page templates: renders pages (evidence: `controllers/main_routes.py`)
- Flask app setup → Flask routes: registers routes (evidence: `app.py`)
- Flask app setup → Rate data manager: configures storage (evidence: `app.py`)
- Flask app setup → NBRB API client: configures client (evidence: `app.py`)
- Flask app setup → Authentication manager: configures accounts (evidence: `app.py`)
- Flask app setup → Date formatting: registers filter (evidence: `app.py`)
- App configuration → Flask app setup: provides settings (evidence: `app.py`)
- Browser interface → Flask routes: submits interactions
