# kaikyborges/investment-wallet-api architecture

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

- Interactive diagram: https://gitdiagram.com/kaikyborges/investment-wallet-api
- Repository: https://github.com/kaikyborges/investment-wallet-api

## Overview

Investment Wallet API is a FastAPI service for user accounts, authenticated investment transactions, current prices, asset positions, and portfolio summaries. The main workflow is a client request through the registered routers, with protected routes resolving the user, reading or writing persisted records, and (for asset and portfolio views) applying portfolio calculations. The README documents Alembic migrations and environment-based configuration. Relationships are shown where excerpts or README statements support them; unsampled internals are not inferred.

Main entry points: [`app/database.py`](https://github.com/kaikyborges/investment-wallet-api/blob/master/app/database.py) (Database sessions), [`app/auth.py`](https://github.com/kaikyborges/investment-wallet-api/blob/master/app/auth.py) (JWT authentication), [`app/db_models.py`](https://github.com/kaikyborges/investment-wallet-api/blob/master/app/db_models.py) (ORM records), [`app/app.py`](https://github.com/kaikyborges/investment-wallet-api/blob/master/app/app.py) (FastAPI app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API surface"]
  node_api_app["FastAPI app<br/>[app.py]"]
  node_user_routes["User routes<br/>[usuarios.py]"]
  node_transaction_routes["Transaction routes<br/>[transacoes.py]"]
  node_asset_routes["Asset routes<br/>[ativos.py]"]
  node_price_routes["Price routes<br/>[precos.py]"]
  node_wallet_routes["Wallet routes<br/>[carteira.py]"]
end

subgraph group_identity["Identity and schemas"]
  node_auth["JWT authentication<br/>[auth.py]"]
  node_schemas["Request schemas<br/>[models.py]"]
  node_config["Environment config<br/>[config.py]"]
end

subgraph group_portfolio["Portfolio domain"]
  node_asset_calculations["Position calculations<br/>[calculos.py]"]
end

subgraph group_persistence["Persistence"]
  node_orm_models["ORM records<br/>[db_models.py]"]
  node_db_session["Database sessions<br/>[database.py]"]
  node_sqlite[("SQLite database")]
  node_migrations["Schema migrations"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_api_app
node_api_app -->|"registers routes"| node_user_routes
node_api_app -->|"registers routes"| node_transaction_routes
node_api_app -->|"registers routes"| node_asset_routes
node_api_app -->|"registers routes"| node_price_routes
node_api_app -->|"registers routes"| node_wallet_routes
node_user_routes -->|"validates input"| node_schemas
node_transaction_routes -->|"validates input"| node_schemas
node_price_routes -->|"validates input"| node_schemas
node_user_routes -->|"queries and creates"| node_orm_models
node_transaction_routes -->|"creates records"| node_orm_models
node_asset_routes -->|"queries transactions"| node_orm_models
node_price_routes -->|"reads and writes"| node_orm_models
node_wallet_routes -->|"queries records"| node_orm_models
node_user_routes -->|"injects session"| node_db_session
node_transaction_routes -->|"injects session"| node_db_session
node_asset_routes -->|"injects session"| node_db_session
node_price_routes -->|"injects session"| node_db_session
node_wallet_routes -->|"injects session"| node_db_session
node_asset_routes -->|"resolves user"| node_auth
node_transaction_routes -->|"resolves user"| node_auth
node_price_routes -->|"resolves user"| node_auth
node_wallet_routes -->|"resolves user"| node_auth
node_auth -->|"looks up user"| node_orm_models
node_auth -->|"injects session"| node_db_session
node_auth -->|"uses JWT settings"| node_config
node_user_routes -->|"uses JWT settings"| node_config
node_asset_routes -->|"calculates positions"| node_asset_calculations
node_wallet_routes -->|"calculates summary"| node_asset_calculations
node_orm_models -->|"uses declarative base"| node_db_session
node_db_session -->|"connects to"| node_sqlite
node_migrations -.->|"updates schema"| node_sqlite

click node_api_app "https://github.com/kaikyborges/investment-wallet-api/blob/master/app/app.py"
click node_user_routes "https://github.com/kaikyborges/investment-wallet-api/blob/master/app/routers/usuarios.py"
click node_transaction_routes "https://github.com/kaikyborges/investment-wallet-api/blob/master/app/routers/transacoes.py"
click node_asset_routes "https://github.com/kaikyborges/investment-wallet-api/blob/master/app/routers/ativos.py"
click node_price_routes "https://github.com/kaikyborges/investment-wallet-api/blob/master/app/routers/precos.py"
click node_wallet_routes "https://github.com/kaikyborges/investment-wallet-api/blob/master/app/routers/carteira.py"
click node_auth "https://github.com/kaikyborges/investment-wallet-api/blob/master/app/auth.py"
click node_schemas "https://github.com/kaikyborges/investment-wallet-api/blob/master/app/models.py"
click node_config "https://github.com/kaikyborges/investment-wallet-api/blob/master/app/config.py"
click node_asset_calculations "https://github.com/kaikyborges/investment-wallet-api/blob/master/app/calculos.py"
click node_orm_models "https://github.com/kaikyborges/investment-wallet-api/blob/master/app/db_models.py"
click node_db_session "https://github.com/kaikyborges/investment-wallet-api/blob/master/app/database.py"
click node_migrations "https://github.com/kaikyborges/investment-wallet-api/tree/master/alembic/versions"

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_api_app,node_user_routes,node_transaction_routes,node_asset_routes,node_price_routes,node_wallet_routes,node_client toneBlue
class node_auth,node_schemas,node_config toneAmber
class node_asset_calculations toneMint
class node_orm_models,node_db_session,node_sqlite,node_migrations toneRose
```

## Components

### API surface

- [FastAPI app](https://github.com/kaikyborges/investment-wallet-api/blob/master/app/app.py): `app/app.py`
- [User routes](https://github.com/kaikyborges/investment-wallet-api/blob/master/app/routers/usuarios.py): `app/routers/usuarios.py`
- [Transaction routes](https://github.com/kaikyborges/investment-wallet-api/blob/master/app/routers/transacoes.py): `app/routers/transacoes.py`
- [Asset routes](https://github.com/kaikyborges/investment-wallet-api/blob/master/app/routers/ativos.py): `app/routers/ativos.py`
- [Price routes](https://github.com/kaikyborges/investment-wallet-api/blob/master/app/routers/precos.py): `app/routers/precos.py`
- [Wallet routes](https://github.com/kaikyborges/investment-wallet-api/blob/master/app/routers/carteira.py): `app/routers/carteira.py`

### Identity and schemas

- [JWT authentication](https://github.com/kaikyborges/investment-wallet-api/blob/master/app/auth.py): `app/auth.py`
- [Request schemas](https://github.com/kaikyborges/investment-wallet-api/blob/master/app/models.py): `app/models.py`
- [Environment config](https://github.com/kaikyborges/investment-wallet-api/blob/master/app/config.py): `app/config.py`

### Portfolio domain

- [Position calculations](https://github.com/kaikyborges/investment-wallet-api/blob/master/app/calculos.py): `app/calculos.py`

### Persistence

- [ORM records](https://github.com/kaikyborges/investment-wallet-api/blob/master/app/db_models.py): `app/db_models.py`
- [Database sessions](https://github.com/kaikyborges/investment-wallet-api/blob/master/app/database.py): `app/database.py`
- **SQLite database**
- [Schema migrations](https://github.com/kaikyborges/investment-wallet-api/tree/master/alembic/versions): `alembic/versions`

### Other components

- **API client**

## Connections

- API client → FastAPI app: sends requests (evidence: `README.md`)
- FastAPI app → User routes: registers routes (evidence: `app/app.py`)
- FastAPI app → Transaction routes: registers routes (evidence: `app/app.py`)
- FastAPI app → Asset routes: registers routes (evidence: `app/app.py`)
- FastAPI app → Price routes: registers routes (evidence: `app/app.py`)
- FastAPI app → Wallet routes: registers routes (evidence: `app/app.py`)
- User routes → Request schemas: validates input (evidence: `app/routers/usuarios.py`)
- Transaction routes → Request schemas: validates input (evidence: `app/routers/transacoes.py`)
- Price routes → Request schemas: validates input (evidence: `app/routers/precos.py`)
- User routes → ORM records: queries and creates (evidence: `app/routers/usuarios.py`)
- Transaction routes → ORM records: creates records (evidence: `app/routers/transacoes.py`)
- Asset routes → ORM records: queries transactions (evidence: `app/routers/ativos.py`)
- Price routes → ORM records: reads and writes (evidence: `app/routers/precos.py`)
- Wallet routes → ORM records: queries records (evidence: `app/routers/carteira.py`)
- User routes → Database sessions: injects session (evidence: `app/routers/usuarios.py`)
- Transaction routes → Database sessions: injects session (evidence: `app/routers/transacoes.py`)
- Asset routes → Database sessions: injects session (evidence: `app/routers/ativos.py`)
- Price routes → Database sessions: injects session (evidence: `app/routers/precos.py`)
- Wallet routes → Database sessions: injects session (evidence: `app/routers/carteira.py`)
- Asset routes → JWT authentication: resolves user (evidence: `app/routers/ativos.py`)
- Transaction routes → JWT authentication: resolves user (evidence: `app/routers/transacoes.py`)
- Price routes → JWT authentication: resolves user (evidence: `app/routers/precos.py`)
- Wallet routes → JWT authentication: resolves user (evidence: `app/routers/carteira.py`)
- JWT authentication → ORM records: looks up user (evidence: `app/auth.py`)
- JWT authentication → Database sessions: injects session (evidence: `app/auth.py`)
- JWT authentication → Environment config: uses JWT settings (evidence: `app/auth.py`)
- User routes → Environment config: uses JWT settings (evidence: `app/routers/usuarios.py`)
- Asset routes → Position calculations: calculates positions (evidence: `app/routers/ativos.py`)
- Wallet routes → Position calculations: calculates summary (evidence: `app/routers/carteira.py`)
- ORM records → Database sessions: uses declarative base (evidence: `app/db_models.py`)
- Database sessions → SQLite database: connects to (evidence: `app/database.py`)
- Schema migrations → SQLite database: updates schema (evidence: `README.md`)
