# hmdank/finetize architecture

> Architecture diagram of the GitHub repository hmdank/finetize, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hmdank/finetize
- Repository: https://github.com/hmdank/finetize

## Overview

##### Project type and purpose
- finetize is a Python‐based, multi‐page analytics and simulation dashboard (built with Streamlit’s “pages” feature).
- The user selects stocks and strategies, runs analysis, simulations, and backtests, then sees interactive plots.
- It’s not a distributed microservice system—rather a single‐process “frontend” (UI) plus layered business logic and data‐access modules.

##### File structure
- Top level:
- Finetize.py    — main Streamlit entrypoint
- pages/1-4 *.py — multi‐page UI (Select, Analyze, Simulate, Backtest)
- functions/    — pure-Python modules for data selection, evaluation, plotting, simulation
- requirements.txt, .devcontainer/ — environment & container config
- Patterns:
- UI layer: `Finetize.py` + `pages/` scripts
- Business-logic layer: `functions/*.py`
- (Implicit) Data layer: either local cache or external market‐data API

##### README for insights
- Streamlit UI with four steps: Select → Analyze → Simulate → Backtest
- Core features: precise plots, realistic assumptions, baseline models
- Libraries (in requirements.txt) likely include pandas, numpy, plotly, streamlit

##### Main components and their interactions
a. UI Layer
- Streamlit main app (Finetize.py) and page modules (`pages/1 Select.py` etc.)
- Presents controls (date pickers, buttons) and canvases for plots/tables
b. Business Logic Layer
- functions/select.py: symbol and date‐range selection
- functions/evaluate.py: statistical analysis of returns
- functions/simulation.py: run Monte Carlo or rule-based simulations
- functions/plots.py: build charts, graphs
c. Data Layer
- External market‐data API client (e.g., yfinance) or local CSV cache
- Caching component (if implemented) under `.conda/Library`—optional
d. Config & DevOps
- .devcontainer: Docker/VS-Code devcontainer.json for consistent environment
- requirements.txt: pinned dependencies

##### Architectural patterns and design principles
- Layered architecture:
UI → Business Logic → Data
- Single‐process, in‐memory data flow
- Clear separation of concerns: plotting, simulating, evaluating, selecting
- Streamlit “pages” pattern for modular UI

##### Detail without over‐engineering
- 4 pages separately to highlight modular UI
- Expose the functions folder’s four modules distinctly
- Call out the devcontainer as your local‐development “ops” component

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer"
        direction TB
        MainApp["Finetize.py"]:::ui
        SelPage["1 Select"]:::ui
        AnaPage["2 Analyze"]:::ui
        SimPage["3 Simulate"]:::ui
        BackPage["4 Backtest"]:::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer (functions/)"
        direction TB
        SelectMod["select.py"]:::logic
        EvalMod["evaluate.py"]:::logic
        SimMod["simulation.py"]:::logic
        PlotMod["plots.py"]:::logic
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        API["Market Data API"]:::data
        Cache["Local CSV Cache"]:::data
    end

    %% DevOps & Config
    subgraph "DevOps & Config"
        direction TB
        DevCont["devcontainer.json"]:::config
        Req["requirements.txt"]:::config
    end

    %% Interactions: UI -> Business Logic
    SelPage -->|"Symbol list & dates"| SelectMod
    SelectMod -->|"Symbol list"| SelPage

    AnaPage -->|"Request stats"| EvalMod
    EvalMod -->|"Stats results"| AnaPage

    SimPage -->|"Sim parameters"| SimMod
    SimMod -->|"Simulation results"| SimPage

    BackPage -->|"Backtest parameters"| SimMod
    SimMod -->|"Backtest results"| BackPage

    %% Plot interactions
    AnaPage -->|"Plot request"| PlotMod
    SimPage -->|"Plot request"| PlotMod
    BackPage -->|"Plot request"| PlotMod
    PlotMod -->|"Plot JSON"| AnaPage
    PlotMod -->|"Plot JSON"| SimPage
    PlotMod -->|"Plot JSON"| BackPage

    %% Business Logic -> Data
    SelectMod -->|"Fetch price series"| API
    EvalMod -->|"Load historical data"| Cache
    SimMod -->|"Fetch historical data"| API
    SimMod -->|"Load cached data"| Cache

    %% DevOps config usage
    MainApp -->|"Environment config"| DevCont
    MainApp -->|"Dependencies"| Req

    %% Click Events
    click MainApp "https://github.com/hmdank/finetize/blob/public/Finetize.py"
    click SelPage "https://github.com/hmdank/finetize/blob/public/pages/1 Select.py"
    click AnaPage "https://github.com/hmdank/finetize/blob/public/pages/2 Analyze.py"
    click SimPage "https://github.com/hmdank/finetize/blob/public/pages/3 Simulate.py"
    click BackPage "https://github.com/hmdank/finetize/blob/public/pages/4 Backtest.py"
    click SelectMod "https://github.com/hmdank/finetize/blob/public/functions/select.py"
    click EvalMod "https://github.com/hmdank/finetize/blob/public/functions/evaluate.py"
    click SimMod "https://github.com/hmdank/finetize/blob/public/functions/simulation.py"
    click PlotMod "https://github.com/hmdank/finetize/blob/public/functions/plots.py"
    click DevCont "https://github.com/hmdank/finetize/blob/public/.devcontainer/devcontainer.json"
    click Req "https://github.com/hmdank/finetize/blob/public/requirements.txt"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#004085,color:#004085,stroke-width:1px
    classDef logic fill:#d4edda,stroke:#155724,color:#155724,stroke-width:1px
    classDef data fill:#fff3cd,stroke:#856404,color:#856404,stroke-width:1px
    classDef config fill:#e2e3e5,stroke:#6c757d,color:#6c757d,stroke-width:1px
```
