# renankin/investment-analyser architecture

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

- Interactive diagram: https://gitdiagram.com/renankin/investment-analyser
- Repository: https://github.com/renankin/investment-analyser

## Overview

Investment Analyser is a local Flask app for managing investment portfolios across accounts. Users record accounts, assets, and transactions; the app can retrieve market histories, persist them locally, and present portfolio valuations, distributions, histories, and return analyses. Its analysis capabilities also include ETF search/comparison and dividend and split handling. The graph follows documented route-to-service responsibilities and indexed source references; some analysis and integration details are documented in the README but their implementation was not sampled, so those links are identified as documented rather than inferred from source.

Main entry points: [`app/repositories`](https://github.com/renankin/investment-analyser/tree/master/app/repositories) (Data repositories), [`app/routes/assets.py`](https://github.com/renankin/investment-analyser/blob/master/app/routes/assets.py) (Asset routes), [`app/services/transaction_service.py`](https://github.com/renankin/investment-analyser/blob/master/app/services/transaction_service.py) (Transaction ledger), [`app/services/price_service.py`](https://github.com/renankin/investment-analyser/blob/master/app/services/price_service.py) (Price histories)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_accounts_routes["Account routes<br/>[accounts.py]"]
  node_assets_routes["Asset routes<br/>[assets.py]"]
  node_transactions_routes["Transaction routes<br/>[transactions.py]"]
  node_homepage["Portfolio dashboard<br/>[homepage.py]"]
  node_portfolio_routes["Portfolio analysis routes"]
  node_market_routes["ETF analysis routes<br/>[market_analysis.py]"]
  node_templates["Portfolio views"]
end

subgraph group_domain["Portfolio domain"]
  node_accounts_service["Account management<br/>[account_service.py]"]
  node_assets_service["Asset management<br/>[asset_service.py]"]
  node_transactions_service["Transaction ledger"]
  node_models["Portfolio records<br/>[models.py]"]
  node_prices_service["Price histories<br/>[price_service.py]"]
  node_dividends_service["Dividend histories"]
  node_splits_service["Stock split adjustment"]
end

subgraph group_data["Persistence"]
  node_repositories["Data repositories"]
  node_database[("SQLite database<br/>[connection.py]")]
end

subgraph group_market["Market data"]
  node_yfinance["Yahoo market data<br/>[yfinance.py]"]
  node_tesouro["Tesouro Direto data<br/>[tesouro_direto.py]"]
end

subgraph group_analysis["Portfolio analysis"]
  node_distribution["Portfolio distribution"]
  node_evolution["Portfolio evolution"]
  node_roi["Returns and IRR<br/>[roi.py]"]
  node_etfs["ETF search and comparison<br/>[etfs.py]"]
end

node_user(("Investor"))

node_user -->|"manages accounts"| node_accounts_routes
node_user -->|"manages portfolio"| node_assets_routes
node_user -->|"records trades"| node_transactions_routes
node_user -->|"views dashboard"| node_homepage
node_user -->|"analyzes returns"| node_portfolio_routes
node_user -->|"compares ETFs"| node_market_routes
node_accounts_routes -->|"calls"| node_accounts_service
node_assets_routes -->|"calls"| node_assets_service
node_assets_routes -->|"updates prices"| node_prices_service
node_assets_routes -->|"updates dividends"| node_dividends_service
node_assets_routes -->|"updates splits"| node_splits_service
node_assets_routes -->|"gets adjusted trades"| node_transactions_service
node_transactions_routes -->|"manages trades"| node_transactions_service
node_homepage -->|"gets allocation"| node_distribution
node_portfolio_routes -->|"plots evolution"| node_evolution
node_portfolio_routes -->|"calculates returns"| node_roi
node_market_routes -->|"searches and compares"| node_etfs
node_accounts_routes -.->|"renders views"| node_templates
node_assets_routes -->|"renders views"| node_templates
node_transactions_routes -.->|"renders views"| node_templates
node_portfolio_routes -.->|"renders views"| node_templates
node_market_routes -.->|"renders views"| node_templates
node_accounts_service -->|"reads and writes"| node_repositories
node_assets_service -->|"reads and writes"| node_repositories
node_transactions_service -->|"reads and writes"| node_repositories
node_prices_service -->|"reads and writes prices"| node_repositories
node_dividends_service -->|"reads and writes dividends"| node_repositories
node_splits_service -->|"reads and writes splits"| node_repositories
node_repositories -->|"queries"| node_database
node_transactions_service -->|"adjusts trades"| node_splits_service
node_prices_service -->|"fetches prices"| node_yfinance
node_prices_service -->|"fetches bond prices"| node_tesouro
node_dividends_service -->|"fetches dividends"| node_yfinance
node_splits_service -->|"fetches splits"| node_yfinance
node_distribution -->|"gets fund data"| node_yfinance
node_etfs -->|"gets ETF data"| node_yfinance
node_distribution -->|"reads prices and trades"| node_repositories
node_evolution -->|"reads portfolio data"| node_repositories
node_evolution -->|"uses trade history"| node_transactions_service
node_roi -->|"reads prices and assets"| node_repositories
node_roi -->|"includes dividends"| node_dividends_service
node_roi -->|"uses trade history"| node_transactions_service
node_etfs -->|"reads ETF assets"| node_repositories
node_accounts_service -->|"uses records"| node_models
node_assets_service -->|"uses records"| node_models
node_transactions_service -->|"uses records"| node_models
node_prices_service -->|"uses records"| node_models
node_dividends_service -->|"uses records"| node_models

click node_accounts_routes "https://github.com/renankin/investment-analyser/blob/master/app/routes/accounts.py"
click node_assets_routes "https://github.com/renankin/investment-analyser/blob/master/app/routes/assets.py"
click node_transactions_routes "https://github.com/renankin/investment-analyser/blob/master/app/routes/transactions.py"
click node_homepage "https://github.com/renankin/investment-analyser/blob/master/app/routes/homepage.py"
click node_portfolio_routes "https://github.com/renankin/investment-analyser/blob/master/app/routes/portfolio_analysis.py"
click node_market_routes "https://github.com/renankin/investment-analyser/blob/master/app/routes/market_analysis.py"
click node_templates "https://github.com/renankin/investment-analyser/tree/master/app/templates"
click node_accounts_service "https://github.com/renankin/investment-analyser/blob/master/app/services/account_service.py"
click node_assets_service "https://github.com/renankin/investment-analyser/blob/master/app/services/asset_service.py"
click node_transactions_service "https://github.com/renankin/investment-analyser/blob/master/app/services/transaction_service.py"
click node_models "https://github.com/renankin/investment-analyser/blob/master/app/models/models.py"
click node_prices_service "https://github.com/renankin/investment-analyser/blob/master/app/services/price_service.py"
click node_dividends_service "https://github.com/renankin/investment-analyser/blob/master/app/services/dividend_service.py"
click node_splits_service "https://github.com/renankin/investment-analyser/blob/master/app/services/stock_split_service.py"
click node_repositories "https://github.com/renankin/investment-analyser/tree/master/app/repositories"
click node_database "https://github.com/renankin/investment-analyser/blob/master/app/db/connection.py"
click node_yfinance "https://github.com/renankin/investment-analyser/blob/master/app/fetchers/yfinance.py"
click node_tesouro "https://github.com/renankin/investment-analyser/blob/master/app/fetchers/tesouro_direto.py"
click node_distribution "https://github.com/renankin/investment-analyser/blob/master/app/services/portfolio_distribution.py"
click node_evolution "https://github.com/renankin/investment-analyser/blob/master/app/services/capital_evolution.py"
click node_roi "https://github.com/renankin/investment-analyser/blob/master/app/services/roi.py"
click node_etfs "https://github.com/renankin/investment-analyser/blob/master/app/services/etfs.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_accounts_routes,node_assets_routes,node_transactions_routes,node_homepage,node_portfolio_routes,node_market_routes,node_templates toneBlue
class node_accounts_service,node_assets_service,node_transactions_service,node_models,node_prices_service,node_dividends_service,node_splits_service toneAmber
class node_repositories,node_database toneMint
class node_yfinance,node_tesouro toneRose
class node_distribution,node_evolution,node_roi,node_etfs,node_user toneIndigo
```

## Components

### Web interface

- [Account routes](https://github.com/renankin/investment-analyser/blob/master/app/routes/accounts.py): `app/routes/accounts.py`
- [Asset routes](https://github.com/renankin/investment-analyser/blob/master/app/routes/assets.py): `app/routes/assets.py`
- [Transaction routes](https://github.com/renankin/investment-analyser/blob/master/app/routes/transactions.py): `app/routes/transactions.py`
- [Portfolio dashboard](https://github.com/renankin/investment-analyser/blob/master/app/routes/homepage.py): `app/routes/homepage.py`
- [Portfolio analysis routes](https://github.com/renankin/investment-analyser/blob/master/app/routes/portfolio_analysis.py): `app/routes/portfolio_analysis.py`
- [ETF analysis routes](https://github.com/renankin/investment-analyser/blob/master/app/routes/market_analysis.py): `app/routes/market_analysis.py`
- [Portfolio views](https://github.com/renankin/investment-analyser/tree/master/app/templates): `app/templates`

### Portfolio domain

- [Account management](https://github.com/renankin/investment-analyser/blob/master/app/services/account_service.py): `app/services/account_service.py`
- [Asset management](https://github.com/renankin/investment-analyser/blob/master/app/services/asset_service.py): `app/services/asset_service.py`
- [Transaction ledger](https://github.com/renankin/investment-analyser/blob/master/app/services/transaction_service.py): `app/services/transaction_service.py`
- [Portfolio records](https://github.com/renankin/investment-analyser/blob/master/app/models/models.py): `app/models/models.py`
- [Price histories](https://github.com/renankin/investment-analyser/blob/master/app/services/price_service.py): `app/services/price_service.py`
- [Dividend histories](https://github.com/renankin/investment-analyser/blob/master/app/services/dividend_service.py): `app/services/dividend_service.py`
- [Stock split adjustment](https://github.com/renankin/investment-analyser/blob/master/app/services/stock_split_service.py): `app/services/stock_split_service.py`

### Persistence

- [Data repositories](https://github.com/renankin/investment-analyser/tree/master/app/repositories): `app/repositories`
- [SQLite database](https://github.com/renankin/investment-analyser/blob/master/app/db/connection.py): `app/db/connection.py`

### Market data

- [Yahoo market data](https://github.com/renankin/investment-analyser/blob/master/app/fetchers/yfinance.py): `app/fetchers/yfinance.py`
- [Tesouro Direto data](https://github.com/renankin/investment-analyser/blob/master/app/fetchers/tesouro_direto.py): `app/fetchers/tesouro_direto.py`

### Portfolio analysis

- [Portfolio distribution](https://github.com/renankin/investment-analyser/blob/master/app/services/portfolio_distribution.py): `app/services/portfolio_distribution.py`
- [Portfolio evolution](https://github.com/renankin/investment-analyser/blob/master/app/services/capital_evolution.py): `app/services/capital_evolution.py`
- [Returns and IRR](https://github.com/renankin/investment-analyser/blob/master/app/services/roi.py): `app/services/roi.py`
- [ETF search and comparison](https://github.com/renankin/investment-analyser/blob/master/app/services/etfs.py): `app/services/etfs.py`

### Other components

- **Investor**

## Connections

- Investor → Account routes: manages accounts (evidence: `README.md`)
- Investor → Asset routes: manages portfolio (evidence: `README.md`)
- Investor → Transaction routes: records trades (evidence: `README.md`)
- Investor → Portfolio dashboard: views dashboard (evidence: `README.md`)
- Investor → Portfolio analysis routes: analyzes returns (evidence: `README.md`)
- Investor → ETF analysis routes: compares ETFs (evidence: `README.md`)
- Account routes → Account management: calls (evidence: `app/routes/accounts.py`)
- Asset routes → Asset management: calls (evidence: `app/routes/assets.py`)
- Asset routes → Price histories: updates prices (evidence: `app/routes/assets.py`)
- Asset routes → Dividend histories: updates dividends (evidence: `app/routes/assets.py`)
- Asset routes → Stock split adjustment: updates splits (evidence: `app/routes/assets.py`)
- Asset routes → Transaction ledger: gets adjusted trades (evidence: `app/routes/assets.py`)
- Transaction routes → Transaction ledger: manages trades (evidence: `app/routes/transactions.py`)
- Portfolio dashboard → Portfolio distribution: gets allocation (evidence: `app/routes/homepage.py`)
- Portfolio analysis routes → Portfolio evolution: plots evolution (evidence: `app/routes/portfolio_analysis.py`)
- Portfolio analysis routes → Returns and IRR: calculates returns (evidence: `app/routes/portfolio_analysis.py`)
- ETF analysis routes → ETF search and comparison: searches and compares (evidence: `app/routes/market_analysis.py`)
- Account routes → Portfolio views: renders views
- Asset routes → Portfolio views: renders views (evidence: `app/routes/assets.py`)
- Transaction routes → Portfolio views: renders views
- Portfolio analysis routes → Portfolio views: renders views
- ETF analysis routes → Portfolio views: renders views
- Account management → Data repositories: reads and writes (evidence: `app/services/account_service.py`)
- Asset management → Data repositories: reads and writes (evidence: `app/services/asset_service.py`)
- Transaction ledger → Data repositories: reads and writes (evidence: `app/services/transaction_service.py`)
- Price histories → Data repositories: reads and writes prices (evidence: `app/services/price_service.py`)
- Dividend histories → Data repositories: reads and writes dividends (evidence: `app/services/dividend_service.py`)
- Stock split adjustment → Data repositories: reads and writes splits (evidence: `app/services/stock_split_service.py`)
- Data repositories → SQLite database: queries (evidence: `app/repositories/transactions.py`)
- Transaction ledger → Stock split adjustment: adjusts trades (evidence: `app/services/transaction_service.py`)
- Price histories → Yahoo market data: fetches prices (evidence: `app/services/price_service.py`)
- Price histories → Tesouro Direto data: fetches bond prices (evidence: `app/services/price_service.py`)
- Dividend histories → Yahoo market data: fetches dividends (evidence: `app/services/dividend_service.py`)
- Stock split adjustment → Yahoo market data: fetches splits (evidence: `app/services/stock_split_service.py`)
- Portfolio distribution → Yahoo market data: gets fund data (evidence: `app/services/portfolio_distribution.py`)
- ETF search and comparison → Yahoo market data: gets ETF data (evidence: `app/services/etfs.py`)
- Portfolio distribution → Data repositories: reads prices and trades (evidence: `app/services/portfolio_distribution.py`)
- Portfolio evolution → Data repositories: reads portfolio data (evidence: `app/services/capital_evolution.py`)
- Portfolio evolution → Transaction ledger: uses trade history (evidence: `app/services/capital_evolution.py`)
- Returns and IRR → Data repositories: reads prices and assets (evidence: `app/services/roi.py`)
- Returns and IRR → Dividend histories: includes dividends (evidence: `app/services/roi.py`)
- Returns and IRR → Transaction ledger: uses trade history (evidence: `app/services/roi.py`)
- ETF search and comparison → Data repositories: reads ETF assets (evidence: `app/services/etfs.py`)
- Account management → Portfolio records: uses records (evidence: `app/services/account_service.py`)
- Asset management → Portfolio records: uses records (evidence: `app/services/asset_service.py`)
- Transaction ledger → Portfolio records: uses records (evidence: `app/services/transaction_service.py`)
- Price histories → Portfolio records: uses records (evidence: `app/services/price_service.py`)
- Dividend histories → Portfolio records: uses records (evidence: `app/services/dividend_service.py`)
