# shahabathar25/h.a.w.k. architecture

> Architecture diagram of the GitHub repository shahabathar25/h.a.w.k., generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shahabathar25/h.a.w.k.
- Repository: https://github.com/shahabathar25/h.a.w.k.

## Overview

##### Project type and purpose
- From the README (“H.A.W.K. – Hierarchical Allocation With Knowledge”) and the file tree, this is a small, self-contained library/application (likely a command-line or programmatic tool) for performing hierarchical portfolio allocation.
- There is no “frontend” folder or web UI; instead, it exposes a main entrypoint (main.py) and a suite of core modules under /core.

##### File structure
- Top‐level files:
- .env.template – environment variable placeholders
- main.py – the CLI or script entrypoint
- test.py – standalone smoke/integration tests
- /core directory: the main functional modules
- data_handler.py – ingestion & normalization of raw market/portfolio data
- engine.py – computes allocation hierarchies and weightings
- executor.py – transforms allocation plans into executable orders or actions
- portfolio.py – model and state of the portfolio (positions, constraints)
- No direct database or web server config is present; data may come from CSVs, APIs, or in-memory structures.

##### Detail—but don’t overthink
- Break the system into as many meaningful components as possible (each .py).
- External dependencies (config, data feeds, broker APIs).

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Orchestration Layer"
        Orchestrator["main.py<br/>CLI Orchestrator"]:::orchestration
    end

    subgraph "Ingestion Layer"
        DataHandler["data_handler.py<br/>Ingestion & Normalization"]:::ingestion
    end

    subgraph "Computation Layer"
        Engine["engine.py<br/>Allocation Engine"]:::computation
    end

    subgraph "Execution Layer"
        Executor["executor.py<br/>Execution Engine"]:::execution
    end

    subgraph "State Layer"
        Portfolio["portfolio.py<br/>Portfolio Model"]:::state
    end

    subgraph "External Data Sources"
        CSV["CSV Files"]:::external
        API["Market API"]:::external
        Env[".env Template"]:::external
    end

    Orchestrator -->|"invokes"| DataHandler
    DataHandler -->|"clean data objects"| Engine
    Engine -->|"allocation plan"| Executor
    Executor -->|"order instructions"| Portfolio
    CSV -->|"raw price data"| DataHandler
    API -->|"market data"| DataHandler
    Env -->|"config vars"| DataHandler
    Env -->|"config vars"| Executor

    subgraph "Test Harness"
        Test["test.py<br/>Test Harness"]:::test
    end
    Test -->|"runs workflows"| Orchestrator

    classDef orchestration fill:#cccccc,stroke:#000,stroke-width:1px;
    classDef ingestion fill:#bbdefb,stroke:#000,stroke-width:1px;
    classDef computation fill:#c8e6c9,stroke:#000,stroke-width:1px;
    classDef execution fill:#ffe0b2,stroke:#000,stroke-width:1px;
    classDef state fill:#fff9c4,stroke:#000,stroke-width:1px;
    classDef external fill:#e1bee7,stroke:#000,stroke-width:1px;
    classDef test fill:#f8bbd0,stroke:#000,stroke-width:1px;

    click Orchestrator "https://github.com/shahabathar25/h.a.w.k./blob/main/main.py"
    click DataHandler "https://github.com/shahabathar25/h.a.w.k./blob/main/core/data_handler.py"
    click Engine "https://github.com/shahabathar25/h.a.w.k./blob/main/core/engine.py"
    click Executor "https://github.com/shahabathar25/h.a.w.k./blob/main/core/executor.py"
    click Portfolio "https://github.com/shahabathar25/h.a.w.k./blob/main/core/portfolio.py"
    click Test "https://github.com/shahabathar25/h.a.w.k./blob/main/test.py"
    click Env "https://github.com/shahabathar25/h.a.w.k./blob/main/.env.template"
```
