# raja549h/sovreign-alpha architecture

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

- Interactive diagram: https://gitdiagram.com/raja549h/sovreign-alpha
- Repository: https://github.com/raja549h/sovreign-alpha

## Overview

#### Purpose and deployment
Sovereign Alpha is a private, Docker-deployed institutional forensic-research and portfolio-intelligence platform. Its primary interactive entry point is the dashboard application; scheduled and CLI workflows also run the research and daily decision pipeline. Hugging Face Space deployment targets port 7860. Paths: `dashboard/app.py`, `Dockerfile`, `.github/workflows/deploy-to-hf.yml`.

#### Dashboard and access boundary
The dashboard is the presentation and operational-control layer, serving portfolio, predictions, research, audit, evidence, health, and run-status views. Authentication and input/security validation form the user-facing trust boundary; a worker and scheduler integration support background execution. Paths: `dashboard/app.py`, `dashboard/auth.py`, `dashboard/security/validator.py`.

#### Daily orchestration and agent decisions
The daily pipeline coordinates market/research processing and decision outputs. A multi-role agent layer separates analysis, risk review, and audit, while daily automation and operations provide executable entry points. This is the principal control flow from acquired data to governed recommendations. Paths: `automation/master_daily.py`, `operations/daily_cycle.py`, `agents/analyst.py`.

#### Market data, regime, and portfolio engine
Data adapters ingest market and institutional inputs, generate signals, and maintain live JSON artifacts. The engine provides the shared data layer and market-regime logic consumed by decision and research workflows; risk parameters are persisted as a data boundary. Paths: `data/market_feed.py`, `data/market_signals.py`, `engine/regime.py`.

#### Research and forensic intelligence
The research subsystem is a substantial independent pipeline: ingest filings/PDFs/transcripts, derive forensic and cross-verification intelligence, score results, and generate deep research notes/PDFs. Macro/FII and portfolio intelligence enrich issuer-level work. Generated research artifacts are retained under the repository data area. Paths: `research/engine.py`, `research/ingestion/filing_fetcher.py`, `research/intelligence/forensic_detector.py`.

#### Persistence, evidence, and integrity
SQLite-backed research/billing artifacts coexist with a PostgreSQL schema definition, indicating local/runtime stores plus a relational deployment target. Observations, transaction JSON, hash proofs, and Merkle/zk proof generation create an evidence and tamper-verification layer distinct from analytical outputs. Paths: `database.py`, `POSTGRES_SCHEMA.sql`, `blockchain/ledger.py`.

#### Validation, historical evaluation, and operations
Historical CSV data and the backtest engine evaluate strategy behavior separately from live workflows. Security/red-team utilities and system/deployment verification scripts provide operational assurance. GitHub Actions schedule the daily pipeline and publish the Docker application. Paths: `backtesting/backtest_engine.py`, `security/red_team.py`, `.github/workflows/daily-pipeline.yml`.

Main entry points: [`dashboard/app.py`](https://github.com/raja549h/sovreign-alpha/blob/main/dashboard/app.py) (Dashboard), [`automation/master_daily.py`](https://github.com/raja549h/sovreign-alpha/blob/main/automation/master_daily.py) (Daily orchestrator), [`engine/regime.py`](https://github.com/raja549h/sovreign-alpha/blob/main/engine/regime.py) (Regime engine), [`database.py`](https://github.com/raja549h/sovreign-alpha/blob/main/database.py) (Runtime artifact store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access &amp; Delivery"]
  node_dashboard["Dashboard<br/>presentation<br/>[app.py]"]
  node_auth["Auth boundary<br/>access-control<br/>[auth.py]"]
  node_input_validation["Input validation<br/>security<br/>[validator.py]"]
  node_docker{{"Docker deployment<br/>container"}}
end

subgraph group_decision["Daily Decision Pipeline"]
  node_daily_orchestrator["Daily orchestrator<br/>pipeline<br/>[master_daily.py]"]
  node_daily_operations["Daily operations<br/>execution-entrypoint<br/>[daily_cycle.py]"]
  node_agent_layer["Agent decision layer<br/>multi-role-agents<br/>[analyst.py]"]
end

subgraph group_research["Research Intelligence"]
  node_research_engine["Research engine<br/>research-pipeline<br/>[engine.py]"]
  node_filing_ingestion["Filing ingestion<br/>document-ingestion<br/>[filing_fetcher.py]"]
  node_forensic_intelligence["Forensic intelligence<br/>cross-verification"]
end

subgraph group_data["Data, Evidence &amp; Evaluation"]
  node_market_adapters["Market adapters &amp; signals<br/>market-data<br/>[market_feed.py]"]
  node_regime_engine["Regime engine<br/>portfolio-engine<br/>[regime.py]"]
  node_runtime_store[("Runtime artifact store<br/>SQLite-artifacts<br/>[database.py]")]
  node_postgres_schema[("PostgreSQL schema<br/>relational-schema")]
  node_evidence_ledger{{"Evidence ledger<br/>integrity-proofs<br/>[ledger.py]"}}
  node_backtest_engine["Backtest engine<br/>historical-evaluation<br/>[backtest_engine.py]"]
end

subgraph group_ops["Automation &amp; Assurance"]
  node_daily_workflow["Daily pipeline workflow<br/>GitHub Actions<br/>[daily-pipeline.yml]"]
  node_hf_deploy["HF deploy workflow<br/>GitHub Actions<br/>[deploy-to-hf.yml]"]
  node_red_team["Security assurance<br/>red-team<br/>[red_team.py]"]
end

node_auth -->|"authorizes access"| node_dashboard
node_input_validation -->|"validates input"| node_dashboard
node_dashboard -->|"controls runs"| node_daily_orchestrator
node_daily_operations -->|"executes"| node_daily_orchestrator
node_daily_workflow -->|"schedules"| node_daily_orchestrator
node_market_adapters -->|"market inputs"| node_regime_engine
node_regime_engine -->|"regime context"| node_daily_orchestrator
node_filing_ingestion -->|"source documents"| node_forensic_intelligence
node_forensic_intelligence -->|"findings"| node_research_engine
node_research_engine -->|"research intelligence"| node_daily_orchestrator
node_daily_orchestrator -->|"decision workload"| node_agent_layer
node_regime_engine -->|"portfolio context"| node_agent_layer
node_agent_layer -->|"governed decisions"| node_evidence_ledger
node_research_engine -->|"research artifacts"| node_runtime_store
node_evidence_ledger -->|"proof records"| node_runtime_store
node_postgres_schema -.->|"deployment persistence model"| node_runtime_store
node_backtest_engine -.->|"evaluates strategies"| node_regime_engine
node_dashboard -->|"reads artifacts"| node_runtime_store
node_hf_deploy -->|"publishes"| node_docker
node_docker -->|"runs"| node_dashboard
node_red_team -.->|"assures boundary"| node_dashboard

click node_dashboard "https://github.com/raja549h/sovreign-alpha/blob/main/dashboard/app.py"
click node_auth "https://github.com/raja549h/sovreign-alpha/blob/main/dashboard/auth.py"
click node_input_validation "https://github.com/raja549h/sovreign-alpha/blob/main/dashboard/security/validator.py"
click node_docker "https://github.com/raja549h/sovreign-alpha/blob/main/Dockerfile"
click node_daily_orchestrator "https://github.com/raja549h/sovreign-alpha/blob/main/automation/master_daily.py"
click node_daily_operations "https://github.com/raja549h/sovreign-alpha/blob/main/operations/daily_cycle.py"
click node_agent_layer "https://github.com/raja549h/sovreign-alpha/blob/main/agents/analyst.py"
click node_market_adapters "https://github.com/raja549h/sovreign-alpha/blob/main/data/market_feed.py"
click node_regime_engine "https://github.com/raja549h/sovreign-alpha/blob/main/engine/regime.py"
click node_research_engine "https://github.com/raja549h/sovreign-alpha/blob/main/research/engine.py"
click node_filing_ingestion "https://github.com/raja549h/sovreign-alpha/blob/main/research/ingestion/filing_fetcher.py"
click node_forensic_intelligence "https://github.com/raja549h/sovreign-alpha/blob/main/research/intelligence/forensic_detector.py"
click node_runtime_store "https://github.com/raja549h/sovreign-alpha/blob/main/database.py"
click node_postgres_schema "https://github.com/raja549h/sovreign-alpha/blob/main/POSTGRES_SCHEMA.sql"
click node_evidence_ledger "https://github.com/raja549h/sovreign-alpha/blob/main/blockchain/ledger.py"
click node_backtest_engine "https://github.com/raja549h/sovreign-alpha/blob/main/backtesting/backtest_engine.py"
click node_daily_workflow "https://github.com/raja549h/sovreign-alpha/blob/main/.github/workflows/daily-pipeline.yml"
click node_hf_deploy "https://github.com/raja549h/sovreign-alpha/blob/main/.github/workflows/deploy-to-hf.yml"
click node_red_team "https://github.com/raja549h/sovreign-alpha/blob/main/security/red_team.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,node_auth,node_input_validation,node_docker toneBlue
class node_daily_orchestrator,node_daily_operations,node_agent_layer toneAmber
class node_research_engine,node_filing_ingestion,node_forensic_intelligence toneMint
class node_market_adapters,node_regime_engine,node_runtime_store,node_postgres_schema,node_evidence_ledger,node_backtest_engine toneRose
class node_daily_workflow,node_hf_deploy,node_red_team toneIndigo
```

## Components

### Access & Delivery

- [Dashboard](https://github.com/raja549h/sovreign-alpha/blob/main/dashboard/app.py): presentation · Interactive portfolio, research, audit, and run-control application. · `dashboard/app.py`
- [Auth boundary](https://github.com/raja549h/sovreign-alpha/blob/main/dashboard/auth.py): access-control · `dashboard/auth.py`
- [Input validation](https://github.com/raja549h/sovreign-alpha/blob/main/dashboard/security/validator.py): security · `dashboard/security/validator.py`
- [Docker deployment](https://github.com/raja549h/sovreign-alpha/blob/main/Dockerfile): container · Serves the Hugging Face Space target on port 7860. · `Dockerfile`

### Daily Decision Pipeline

- [Daily orchestrator](https://github.com/raja549h/sovreign-alpha/blob/main/automation/master_daily.py): pipeline · Coordinates daily market, research, and decision processing. · `automation/master_daily.py`
- [Daily operations](https://github.com/raja549h/sovreign-alpha/blob/main/operations/daily_cycle.py): execution-entrypoint · `operations/daily_cycle.py`
- [Agent decision layer](https://github.com/raja549h/sovreign-alpha/blob/main/agents/analyst.py): multi-role-agents · Analysis, risk review, and audit govern recommendations. · `agents/analyst.py`

### Research Intelligence

- [Research engine](https://github.com/raja549h/sovreign-alpha/blob/main/research/engine.py): research-pipeline · Runs issuer research, scoring, and report generation. · `research/engine.py`
- [Filing ingestion](https://github.com/raja549h/sovreign-alpha/blob/main/research/ingestion/filing_fetcher.py): document-ingestion · Acquires filings, PDFs, and transcripts. · `research/ingestion/filing_fetcher.py`
- [Forensic intelligence](https://github.com/raja549h/sovreign-alpha/blob/main/research/intelligence/forensic_detector.py): cross-verification · Derives forensic findings and verification signals. · `research/intelligence/forensic_detector.py`

### Data, Evidence & Evaluation

- [Market adapters & signals](https://github.com/raja549h/sovreign-alpha/blob/main/data/market_feed.py): market-data · Ingests market and institutional inputs and produces live JSON signals. · `data/market_feed.py`
- [Regime engine](https://github.com/raja549h/sovreign-alpha/blob/main/engine/regime.py): portfolio-engine · Shared market-regime and portfolio intelligence layer. · `engine/regime.py`
- [Runtime artifact store](https://github.com/raja549h/sovreign-alpha/blob/main/database.py): SQLite-artifacts · Retains research and billing artifacts locally. · `database.py`
- [PostgreSQL schema](https://github.com/raja549h/sovreign-alpha/blob/main/POSTGRES_SCHEMA.sql): relational-schema · Relational deployment persistence target. · `POSTGRES_SCHEMA.sql`
- [Evidence ledger](https://github.com/raja549h/sovreign-alpha/blob/main/blockchain/ledger.py): integrity-proofs · Records observations and transaction hashes with Merkle/zk proofs. · `blockchain/ledger.py`
- [Backtest engine](https://github.com/raja549h/sovreign-alpha/blob/main/backtesting/backtest_engine.py): historical-evaluation · Evaluates strategies against historical CSV data. · `backtesting/backtest_engine.py`

### Automation & Assurance

- [Daily pipeline workflow](https://github.com/raja549h/sovreign-alpha/blob/main/.github/workflows/daily-pipeline.yml): GitHub Actions · Schedules the daily decision pipeline. · `.github/workflows/daily-pipeline.yml`
- [HF deploy workflow](https://github.com/raja549h/sovreign-alpha/blob/main/.github/workflows/deploy-to-hf.yml): GitHub Actions · Publishes the Docker application to Hugging Face. · `.github/workflows/deploy-to-hf.yml`
- [Security assurance](https://github.com/raja549h/sovreign-alpha/blob/main/security/red_team.py): red-team · Operational security and deployment verification utilities. · `security/red_team.py`

## Connections

- Auth boundary → Dashboard: authorizes access
- Input validation → Dashboard: validates input
- Dashboard → Daily orchestrator: controls runs
- Daily operations → Daily orchestrator: executes
- Daily pipeline workflow → Daily orchestrator: schedules
- Market adapters & signals → Regime engine: market inputs
- Regime engine → Daily orchestrator: regime context
- Filing ingestion → Forensic intelligence: source documents
- Forensic intelligence → Research engine: findings
- Research engine → Daily orchestrator: research intelligence
- Daily orchestrator → Agent decision layer: decision workload
- Regime engine → Agent decision layer: portfolio context
- Agent decision layer → Evidence ledger: governed decisions
- Research engine → Runtime artifact store: research artifacts
- Evidence ledger → Runtime artifact store: proof records
- PostgreSQL schema → Runtime artifact store: deployment persistence model
- Backtest engine → Regime engine: evaluates strategies
- Dashboard → Runtime artifact store: reads artifacts
- HF deploy workflow → Docker deployment: publishes
- Docker deployment → Dashboard: runs
- Security assurance → Dashboard: assures boundary
