# rusik636/nalogo architecture

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

- Interactive diagram: https://gitdiagram.com/rusik636/nalogo
- Repository: https://github.com/rusik636/nalogo

## Overview

NaloGO is an asynchronous Python client for Russia’s Moy Nalog self-employed tax API. The principal workflow is to authenticate a user, activate a client, then create or cancel income receipts; the library also exposes receipt, profile, payment-method, and tax-reporting APIs. The graph includes the shared HTTP/authentication layer, timezone normalization, and DTOs. Some API modules are unsampled, so their capabilities are grounded in the README and module references; unsupported internal call details are omitted.

Main entry points: [`nalogo/client.py`](https://github.com/rusik636/nalogo/blob/main/nalogo/client.py) (Client), [`nalogo/_http.py`](https://github.com/rusik636/nalogo/blob/main/nalogo/_http.py) (HTTP middleware), [`nalogo/auth.py`](https://github.com/rusik636/nalogo/blob/main/nalogo/auth.py) (Authentication), [`nalogo/income.py`](https://github.com/rusik636/nalogo/blob/main/nalogo/income.py) (Income and cancellation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_facade["Client facade"]
  node_client["Client<br/>[client.py]"]
end

subgraph group_auth_transport["Auth and transport"]
  node_auth["Authentication<br/>[auth.py]"]
  node_http["HTTP middleware<br/>[_http.py]"]
end

subgraph group_domain_apis["Domain APIs"]
  node_income["Income and cancellation<br/>[income.py]"]
  node_receipt["Receipt operations<br/>[receipt.py]"]
  node_user["User profile<br/>[user.py]"]
  node_payment["Payment methods<br/>[payment_type.py]"]
  node_tax["Tax reporting<br/>[tax.py]"]
end

subgraph group_models_errors["Models and errors"]
  node_timezone["Timezone handling<br/>[timezone.py]"]
  node_income_dto["Income models<br/>[income.py]"]
  node_device_dto["Device model<br/>[device.py]"]
  node_invoice_dto["Invoice model<br/>[invoice.py]"]
  node_payment_dto["Payment models<br/>[payment_type.py]"]
  node_tax_dto["Tax models<br/>[tax.py]"]
  node_user_dto["User models<br/>[user.py]"]
  node_exceptions["Domain errors<br/>[exceptions.py]"]
end

node_developer(("Library user"))
node_moy_nalog{{"Moy Nalog API"}}

node_developer -->|"configures and calls"| node_client
node_client -->|"delegates auth"| node_auth
node_client -->|"shares client"| node_http
node_client -->|"creates API"| node_income
node_client -->|"creates API"| node_receipt
node_client -->|"creates API"| node_user
node_client -->|"creates API"| node_payment
node_client -->|"creates API"| node_tax
node_auth -->|"refreshes through"| node_http
node_auth -->|"builds device data"| node_device_dto
node_auth -->|"requests tokens"| node_moy_nalog
node_income -->|"sends requests"| node_http
node_receipt -->|"uses transport"| node_http
node_user -->|"uses transport"| node_http
node_payment -->|"uses transport"| node_http
node_tax -->|"uses transport"| node_http
node_http -->|"sends API requests"| node_moy_nalog
node_income -->|"builds requests"| node_income_dto
node_income -->|"normalizes time"| node_timezone
node_income_dto -->|"serializes time"| node_timezone
node_user -.->|"returns profile data"| node_user_dto
node_payment -.->|"returns payment data"| node_payment_dto
node_tax -.->|"returns tax data"| node_tax_dto
node_http -->|"raises API errors"| node_exceptions
node_timezone -->|"raises input errors"| node_exceptions

click node_client "https://github.com/rusik636/nalogo/blob/main/nalogo/client.py"
click node_auth "https://github.com/rusik636/nalogo/blob/main/nalogo/auth.py"
click node_http "https://github.com/rusik636/nalogo/blob/main/nalogo/_http.py"
click node_income "https://github.com/rusik636/nalogo/blob/main/nalogo/income.py"
click node_receipt "https://github.com/rusik636/nalogo/blob/main/nalogo/receipt.py"
click node_user "https://github.com/rusik636/nalogo/blob/main/nalogo/user.py"
click node_payment "https://github.com/rusik636/nalogo/blob/main/nalogo/payment_type.py"
click node_tax "https://github.com/rusik636/nalogo/blob/main/nalogo/tax.py"
click node_timezone "https://github.com/rusik636/nalogo/blob/main/nalogo/timezone.py"
click node_income_dto "https://github.com/rusik636/nalogo/blob/main/nalogo/dto/income.py"
click node_device_dto "https://github.com/rusik636/nalogo/blob/main/nalogo/dto/device.py"
click node_invoice_dto "https://github.com/rusik636/nalogo/blob/main/nalogo/dto/invoice.py"
click node_payment_dto "https://github.com/rusik636/nalogo/blob/main/nalogo/dto/payment_type.py"
click node_tax_dto "https://github.com/rusik636/nalogo/blob/main/nalogo/dto/tax.py"
click node_user_dto "https://github.com/rusik636/nalogo/blob/main/nalogo/dto/user.py"
click node_exceptions "https://github.com/rusik636/nalogo/blob/main/nalogo/exceptions.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_client,node_developer toneBlue
class node_auth,node_http toneAmber
class node_income,node_receipt,node_user,node_payment,node_tax,node_moy_nalog toneMint
class node_timezone,node_income_dto,node_device_dto,node_invoice_dto,node_payment_dto,node_tax_dto,node_user_dto,node_exceptions toneRose
```

## Components

### Client facade

- [Client](https://github.com/rusik636/nalogo/blob/main/nalogo/client.py): `nalogo/client.py`

### Auth and transport

- [Authentication](https://github.com/rusik636/nalogo/blob/main/nalogo/auth.py): `nalogo/auth.py`
- [HTTP middleware](https://github.com/rusik636/nalogo/blob/main/nalogo/_http.py): `nalogo/_http.py`

### Domain APIs

- [Income and cancellation](https://github.com/rusik636/nalogo/blob/main/nalogo/income.py): `nalogo/income.py`
- [Receipt operations](https://github.com/rusik636/nalogo/blob/main/nalogo/receipt.py): `nalogo/receipt.py`
- [User profile](https://github.com/rusik636/nalogo/blob/main/nalogo/user.py): `nalogo/user.py`
- [Payment methods](https://github.com/rusik636/nalogo/blob/main/nalogo/payment_type.py): `nalogo/payment_type.py`
- [Tax reporting](https://github.com/rusik636/nalogo/blob/main/nalogo/tax.py): `nalogo/tax.py`

### Models and errors

- [Timezone handling](https://github.com/rusik636/nalogo/blob/main/nalogo/timezone.py): `nalogo/timezone.py`
- [Income models](https://github.com/rusik636/nalogo/blob/main/nalogo/dto/income.py): `nalogo/dto/income.py`
- [Device model](https://github.com/rusik636/nalogo/blob/main/nalogo/dto/device.py): `nalogo/dto/device.py`
- [Invoice model](https://github.com/rusik636/nalogo/blob/main/nalogo/dto/invoice.py): `nalogo/dto/invoice.py`
- [Payment models](https://github.com/rusik636/nalogo/blob/main/nalogo/dto/payment_type.py): `nalogo/dto/payment_type.py`
- [Tax models](https://github.com/rusik636/nalogo/blob/main/nalogo/dto/tax.py): `nalogo/dto/tax.py`
- [User models](https://github.com/rusik636/nalogo/blob/main/nalogo/dto/user.py): `nalogo/dto/user.py`
- [Domain errors](https://github.com/rusik636/nalogo/blob/main/nalogo/exceptions.py): `nalogo/exceptions.py`

### Other components

- **Library user**
- **Moy Nalog API**

## Connections

- Library user → Client: configures and calls (evidence: `README.md`)
- Client → Authentication: delegates auth (evidence: `nalogo/client.py`)
- Client → HTTP middleware: shares client (evidence: `nalogo/client.py`)
- Client → Income and cancellation: creates API (evidence: `nalogo/client.py`)
- Client → Receipt operations: creates API (evidence: `nalogo/client.py`)
- Client → User profile: creates API (evidence: `nalogo/client.py`)
- Client → Payment methods: creates API (evidence: `nalogo/client.py`)
- Client → Tax reporting: creates API (evidence: `nalogo/client.py`)
- Authentication → HTTP middleware: refreshes through (evidence: `nalogo/_http.py`)
- Authentication → Device model: builds device data (evidence: `nalogo/auth.py`)
- Authentication → Moy Nalog API: requests tokens (evidence: `nalogo/auth.py`)
- Income and cancellation → HTTP middleware: sends requests (evidence: `nalogo/income.py`)
- Receipt operations → HTTP middleware: uses transport (evidence: `nalogo/receipt.py`)
- User profile → HTTP middleware: uses transport (evidence: `nalogo/user.py`)
- Payment methods → HTTP middleware: uses transport (evidence: `nalogo/payment_type.py`)
- Tax reporting → HTTP middleware: uses transport (evidence: `nalogo/tax.py`)
- HTTP middleware → Moy Nalog API: sends API requests (evidence: `nalogo/_http.py`)
- Income and cancellation → Income models: builds requests (evidence: `nalogo/income.py`)
- Income and cancellation → Timezone handling: normalizes time (evidence: `nalogo/income.py`)
- Income models → Timezone handling: serializes time (evidence: `nalogo/dto/income.py`)
- User profile → User models: returns profile data
- Payment methods → Payment models: returns payment data
- Tax reporting → Tax models: returns tax data
- HTTP middleware → Domain errors: raises API errors (evidence: `nalogo/_http.py`)
- Timezone handling → Domain errors: raises input errors (evidence: `nalogo/timezone.py`)
