# jenisezyang/universe architecture

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

- Interactive diagram: https://gitdiagram.com/jenisezyang/universe
- Repository: https://github.com/jenisezyang/universe

## Overview

Universe is a Streamlit portfolio-analytics app for a fixed 10-stock universe. Users choose equal, market-cap, or custom weights; the dashboard loads market data, presents performance, risk, attribution, and allocation analyses, and can show Black–Litterman expected returns and optimized weights. The graph separates those user-facing analytics from data retrieval and the optimizer’s internal stages. Edges reflect calls or documented data flow in the excerpts; the Yahoo Finance connection is shown as an external dependency.

Main entry points: [`dashboard.py`](https://github.com/jenisezyang/universe/blob/main/dashboard.py) (Streamlit dashboard), [`config.py`](https://github.com/jenisezyang/universe/blob/main/config.py) (Universe settings), [`bl_model.py`](https://github.com/jenisezyang/universe/blob/main/bl_model.py) (BL pipeline), [`data.py`](https://github.com/jenisezyang/universe/blob/main/data.py) (Price and cap data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Dashboard"]
  node_dashboard["Streamlit dashboard<br/>[dashboard.py]"]
end

subgraph group_inputs["Market data"]
  node_settings["Universe settings<br/>[config.py]"]
  node_marketdata["Price and cap data<br/>[data.py]"]
end

subgraph group_analytics["Portfolio analytics"]
  node_performance["Performance metrics<br/>[metrics.py]"]
  node_risk["Risk metrics<br/>[metrics.py]"]
  node_attribution["Return attribution<br/>[metrics.py]"]
  node_allocation["Sector allocation<br/>[metrics.py]"]
  node_covariance["Covariance model<br/>[metrics.py]"]
end

subgraph group_optimization["Black–Litterman"]
  node_blpipeline["BL pipeline<br/>[bl_model.py]"]
  node_implied["Implied returns<br/>[bl_model.py]"]
  node_viewmatrices["View matrices<br/>[bl_model.py]"]
  node_posterior["Posterior returns<br/>[bl_model.py]"]
  node_optimizer["Max-Sharpe weights<br/>[bl_model.py]"]
end

node_investor(("Investor"))
node_yahoo["Yahoo Finance"]

node_investor -->|"uses"| node_dashboard
node_dashboard -->|"reads settings"| node_settings
node_dashboard -->|"loads data"| node_marketdata
node_marketdata -->|"fetches prices and caps"| node_yahoo
node_marketdata -->|"reads universe"| node_settings
node_marketdata -->|"returns data"| node_dashboard
node_dashboard -->|"computes returns and summary"| node_performance
node_dashboard -->|"computes risk"| node_risk
node_dashboard -->|"computes attribution"| node_attribution
node_dashboard -->|"computes sector weights"| node_allocation
node_dashboard -->|"requests covariance"| node_covariance
node_performance -->|"reads risk settings"| node_settings
node_risk -->|"reads risk settings"| node_settings
node_attribution -->|"reads sectors"| node_settings
node_allocation -->|"reads sectors"| node_settings
node_covariance -->|"reads annualization"| node_settings
node_dashboard -->|"runs optimization"| node_blpipeline
node_dashboard -->|"passes covariance and market weights"| node_blpipeline
node_blpipeline -->|"computes prior"| node_implied
node_blpipeline -->|"blends views"| node_posterior
node_blpipeline -->|"optimizes weights"| node_optimizer
node_posterior -->|"gets prior"| node_implied
node_posterior -->|"builds view inputs"| node_viewmatrices
node_implied -->|"reads risk aversion"| node_settings
node_viewmatrices -->|"reads views"| node_settings
node_optimizer -->|"reads risk-free rate"| node_settings

click node_dashboard "https://github.com/jenisezyang/universe/blob/main/dashboard.py"
click node_settings "https://github.com/jenisezyang/universe/blob/main/config.py"
click node_marketdata "https://github.com/jenisezyang/universe/blob/main/data.py"
click node_performance "https://github.com/jenisezyang/universe/blob/main/metrics.py"
click node_risk "https://github.com/jenisezyang/universe/blob/main/metrics.py"
click node_attribution "https://github.com/jenisezyang/universe/blob/main/metrics.py"
click node_allocation "https://github.com/jenisezyang/universe/blob/main/metrics.py"
click node_covariance "https://github.com/jenisezyang/universe/blob/main/metrics.py"
click node_blpipeline "https://github.com/jenisezyang/universe/blob/main/bl_model.py"
click node_implied "https://github.com/jenisezyang/universe/blob/main/bl_model.py"
click node_viewmatrices "https://github.com/jenisezyang/universe/blob/main/bl_model.py"
click node_posterior "https://github.com/jenisezyang/universe/blob/main/bl_model.py"
click node_optimizer "https://github.com/jenisezyang/universe/blob/main/bl_model.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_dashboard toneBlue
class node_settings,node_marketdata toneAmber
class node_performance,node_risk,node_attribution,node_allocation,node_covariance toneMint
class node_blpipeline,node_implied,node_viewmatrices,node_posterior,node_optimizer toneRose
class node_investor,node_yahoo toneIndigo
```

## Components

### Dashboard

- [Streamlit dashboard](https://github.com/jenisezyang/universe/blob/main/dashboard.py): `dashboard.py`

### Market data

- [Universe settings](https://github.com/jenisezyang/universe/blob/main/config.py): `config.py`
- [Price and cap data](https://github.com/jenisezyang/universe/blob/main/data.py): `data.py`

### Portfolio analytics

- [Performance metrics](https://github.com/jenisezyang/universe/blob/main/metrics.py): `metrics.py`
- [Risk metrics](https://github.com/jenisezyang/universe/blob/main/metrics.py): `metrics.py`
- [Return attribution](https://github.com/jenisezyang/universe/blob/main/metrics.py): `metrics.py`
- [Sector allocation](https://github.com/jenisezyang/universe/blob/main/metrics.py): `metrics.py`
- [Covariance model](https://github.com/jenisezyang/universe/blob/main/metrics.py): `metrics.py`

### Black–Litterman

- [BL pipeline](https://github.com/jenisezyang/universe/blob/main/bl_model.py): `bl_model.py`
- [Implied returns](https://github.com/jenisezyang/universe/blob/main/bl_model.py): `bl_model.py`
- [View matrices](https://github.com/jenisezyang/universe/blob/main/bl_model.py): `bl_model.py`
- [Posterior returns](https://github.com/jenisezyang/universe/blob/main/bl_model.py): `bl_model.py`
- [Max-Sharpe weights](https://github.com/jenisezyang/universe/blob/main/bl_model.py): `bl_model.py`

### Other components

- **Investor**
- **Yahoo Finance**

## Connections

- Investor → Streamlit dashboard: uses (evidence: `README.md`)
- Streamlit dashboard → Universe settings: reads settings (evidence: `dashboard.py`)
- Streamlit dashboard → Price and cap data: loads data (evidence: `dashboard.py`)
- Price and cap data → Yahoo Finance: fetches prices and caps (evidence: `data.py`)
- Price and cap data → Universe settings: reads universe (evidence: `data.py`)
- Price and cap data → Streamlit dashboard: returns data (evidence: `dashboard.py`)
- Streamlit dashboard → Performance metrics: computes returns and summary (evidence: `dashboard.py`)
- Streamlit dashboard → Risk metrics: computes risk (evidence: `dashboard.py`)
- Streamlit dashboard → Return attribution: computes attribution (evidence: `dashboard.py`)
- Streamlit dashboard → Sector allocation: computes sector weights (evidence: `dashboard.py`)
- Streamlit dashboard → Covariance model: requests covariance (evidence: `dashboard.py`)
- Performance metrics → Universe settings: reads risk settings (evidence: `metrics.py`)
- Risk metrics → Universe settings: reads risk settings (evidence: `metrics.py`)
- Return attribution → Universe settings: reads sectors (evidence: `metrics.py`)
- Sector allocation → Universe settings: reads sectors (evidence: `metrics.py`)
- Covariance model → Universe settings: reads annualization (evidence: `metrics.py`)
- Streamlit dashboard → BL pipeline: runs optimization (evidence: `dashboard.py`)
- Streamlit dashboard → BL pipeline: passes covariance and market weights (evidence: `dashboard.py`)
- BL pipeline → Implied returns: computes prior (evidence: `bl_model.py`)
- BL pipeline → Posterior returns: blends views (evidence: `bl_model.py`)
- BL pipeline → Max-Sharpe weights: optimizes weights (evidence: `bl_model.py`)
- Posterior returns → Implied returns: gets prior (evidence: `bl_model.py`)
- Posterior returns → View matrices: builds view inputs (evidence: `bl_model.py`)
- Implied returns → Universe settings: reads risk aversion (evidence: `bl_model.py`)
- View matrices → Universe settings: reads views (evidence: `bl_model.py`)
- Max-Sharpe weights → Universe settings: reads risk-free rate (evidence: `bl_model.py`)
