# tienbob/intelligence-platform architecture

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

- Interactive diagram: https://gitdiagram.com/tienbob/intelligence-platform
- Repository: https://github.com/tienbob/intelligence-platform

## Overview

This is an AI-powered investment research product: users browse market and company data, request analysis, and explore portfolio, alert, and backtest results. The React application calls a Rails gateway; Rails owns authentication and user-company access grants, while forwarding Python-owned data and analysis requests. Python mounts enabled domain APIs and runs the domain-neutral intelligence pipeline with Stock-specific ingestion, retrieval, LLM analysis, validation, and scoring. The README documents additional pipeline stages beyond the sampled excerpts; uncertain internal stage wiring is not expanded here.

Main entry points: [`intelligence-platform-stock/app/intelligence/pipeline.py`](https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-stock/app/intelligence/pipeline.py) (Intelligence pipeline), [`intelligence-platform-api/config/routes.rb`](https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-api/config/routes.rb) (API routes), [`intelligence-platform-frontend/src/App.jsx`](https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-frontend/src/App.jsx) (Research app), [`intelligence-platform-api/app/controllers/api/v1/proxy_controller.rb`](https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-api/app/controllers/api/v1/proxy_controller.rb) (Python proxy)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Research UI"]
  node_webapp["Research app<br/>[App.jsx]"]
  node_api_client["API client<br/>[api.js]"]
  node_auth_ui["Auth client<br/>[auth.jsx]"]
end

subgraph group_gateway["Rails Gateway"]
  node_rails_routes["API routes<br/>[routes.rb]"]
  node_auth["Authentication<br/>[auth_controller.rb]"]
  node_user_store[("User records<br/>[user.rb]")]
  node_proxy["Python proxy"]
  node_grant_store[("Company grants<br/>[user_company.rb]")]
  node_python_client["Python client<br/>[python_client.rb]"]
end

subgraph group_framework["Intelligence Framework"]
  node_pipeline["Intelligence pipeline<br/>[pipeline.py]"]
  node_rag["Generic RAG<br/>[service.py]"]
  node_llm["LLM engine<br/>[client.py]"]
  node_evidence["Evidence services<br/>[service.py]"]
  node_database[("Platform database<br/>[database.py]")]
end

subgraph group_stock["Stock Domain"]
  node_python_app["Domain API host<br/>[main.py]"]
  node_stock_api["Stock endpoints<br/>[router.py]"]
  node_pipeline_factory["Stock pipeline factory"]
  node_ingestion_worker["Data ingestion"]
  node_embedding_worker["Embedding ingestion"]
  node_stock_scoring["Stock analysis services"]
end

node_user(("Investor"))
node_market_sources{{"Market data providers"}}
node_result["Research results"]

node_user -->|"uses"| node_webapp
node_webapp -->|"authenticates via"| node_auth_ui
node_webapp -->|"requests data"| node_api_client
node_auth_ui -->|"calls auth routes"| node_rails_routes
node_api_client -->|"calls API routes"| node_rails_routes
node_rails_routes -->|"dispatches auth"| node_auth
node_auth -->|"reads/writes"| node_user_store
node_rails_routes -->|"dispatches data"| node_proxy
node_proxy -->|"creates access grant"| node_grant_store
node_proxy -->|"forwards requests"| node_python_client
node_python_client -->|"calls internal API"| node_python_app
node_python_app -->|"mounts domain routes"| node_stock_api
node_stock_api -->|"starts analysis"| node_pipeline_factory
node_pipeline_factory -->|"constructs and runs"| node_pipeline
node_pipeline_factory -->|"wires Stock services"| node_stock_scoring
node_pipeline -->|"collects evidence"| node_evidence
node_pipeline -->|"retrieves context"| node_rag
node_pipeline -->|"generates analysis"| node_llm
node_pipeline -->|"scores result"| node_stock_scoring
node_pipeline -->|"returns analysis"| node_result
node_ingestion_worker -->|"fetches market data"| node_market_sources
node_ingestion_worker -->|"persists ingested data"| node_database
node_embedding_worker -->|"reads and persists sources"| node_database
node_embedding_worker -->|"uses embedding ingestion"| node_stock_scoring
node_rag -->|"retrieves indexed context"| node_database
node_llm -->|"produces structured output"| node_result

click node_webapp "https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-frontend/src/App.jsx"
click node_api_client "https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-frontend/src/services/api.js"
click node_auth_ui "https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-frontend/src/services/auth.jsx"
click node_rails_routes "https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-api/config/routes.rb"
click node_auth "https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-api/app/controllers/api/v1/auth_controller.rb"
click node_user_store "https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-api/app/models/user.rb"
click node_proxy "https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-api/app/controllers/api/v1/proxy_controller.rb"
click node_grant_store "https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-api/app/models/user_company.rb"
click node_python_client "https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-api/app/services/python_client.rb"
click node_python_app "https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-stock/app/main.py"
click node_stock_api "https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-stock/app/domains/stock/api/router.py"
click node_pipeline_factory "https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-stock/app/domains/stock/pipeline_factory.py"
click node_pipeline "https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-stock/app/intelligence/pipeline.py"
click node_ingestion_worker "https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-stock/app/domains/stock/workers/ingestion_worker.py"
click node_embedding_worker "https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-stock/app/domains/stock/workers/embedding_worker.py"
click node_stock_scoring "https://github.com/tienbob/intelligence-platform/tree/migration/embedding/intelligence-platform-stock/app/domains/stock/scoring"
click node_rag "https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-stock/app/intelligence/rag/service.py"
click node_llm "https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-stock/app/intelligence/llm/client.py"
click node_evidence "https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-stock/app/intelligence/evidence/service.py"
click node_database "https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-stock/app/core/database.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_webapp,node_api_client,node_auth_ui toneBlue
class node_rails_routes,node_auth,node_user_store,node_proxy,node_grant_store,node_python_client toneAmber
class node_pipeline,node_rag,node_llm,node_evidence,node_database toneMint
class node_python_app,node_stock_api,node_pipeline_factory,node_ingestion_worker,node_embedding_worker,node_stock_scoring toneRose
class node_user,node_market_sources,node_result toneIndigo
```

## Components

### Research UI

- [Research app](https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-frontend/src/App.jsx): `intelligence-platform-frontend/src/App.jsx`
- [API client](https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-frontend/src/services/api.js): `intelligence-platform-frontend/src/services/api.js`
- [Auth client](https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-frontend/src/services/auth.jsx): `intelligence-platform-frontend/src/services/auth.jsx`

### Rails Gateway

- [API routes](https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-api/config/routes.rb): `intelligence-platform-api/config/routes.rb`
- [Authentication](https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-api/app/controllers/api/v1/auth_controller.rb): `intelligence-platform-api/app/controllers/api/v1/auth_controller.rb`
- [User records](https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-api/app/models/user.rb): `intelligence-platform-api/app/models/user.rb`
- [Python proxy](https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-api/app/controllers/api/v1/proxy_controller.rb): `intelligence-platform-api/app/controllers/api/v1/proxy_controller.rb`
- [Company grants](https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-api/app/models/user_company.rb): `intelligence-platform-api/app/models/user_company.rb`
- [Python client](https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-api/app/services/python_client.rb): `intelligence-platform-api/app/services/python_client.rb`

### Intelligence Framework

- [Intelligence pipeline](https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-stock/app/intelligence/pipeline.py): `intelligence-platform-stock/app/intelligence/pipeline.py`
- [Generic RAG](https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-stock/app/intelligence/rag/service.py): `intelligence-platform-stock/app/intelligence/rag/service.py`
- [LLM engine](https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-stock/app/intelligence/llm/client.py): `intelligence-platform-stock/app/intelligence/llm/client.py`
- [Evidence services](https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-stock/app/intelligence/evidence/service.py): `intelligence-platform-stock/app/intelligence/evidence/service.py`
- [Platform database](https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-stock/app/core/database.py): `intelligence-platform-stock/app/core/database.py`

### Stock Domain

- [Domain API host](https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-stock/app/main.py): `intelligence-platform-stock/app/main.py`
- [Stock endpoints](https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-stock/app/domains/stock/api/router.py): `intelligence-platform-stock/app/domains/stock/api/router.py`
- [Stock pipeline factory](https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-stock/app/domains/stock/pipeline_factory.py): `intelligence-platform-stock/app/domains/stock/pipeline_factory.py`
- [Data ingestion](https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-stock/app/domains/stock/workers/ingestion_worker.py): `intelligence-platform-stock/app/domains/stock/workers/ingestion_worker.py`
- [Embedding ingestion](https://github.com/tienbob/intelligence-platform/blob/migration/embedding/intelligence-platform-stock/app/domains/stock/workers/embedding_worker.py): `intelligence-platform-stock/app/domains/stock/workers/embedding_worker.py`
- [Stock analysis services](https://github.com/tienbob/intelligence-platform/tree/migration/embedding/intelligence-platform-stock/app/domains/stock/scoring): `intelligence-platform-stock/app/domains/stock/scoring`

### Other components

- **Investor**
- **Market data providers**
- **Research results**

## Connections

- Investor → Research app: uses
- Research app → Auth client: authenticates via
- Research app → API client: requests data
- Auth client → API routes: calls auth routes
- API client → API routes: calls API routes
- API routes → Authentication: dispatches auth
- Authentication → User records: reads/writes
- API routes → Python proxy: dispatches data
- Python proxy → Company grants: creates access grant
- Python proxy → Python client: forwards requests
- Python client → Domain API host: calls internal API
- Domain API host → Stock endpoints: mounts domain routes
- Stock endpoints → Stock pipeline factory: starts analysis
- Stock pipeline factory → Intelligence pipeline: constructs and runs
- Stock pipeline factory → Stock analysis services: wires Stock services
- Intelligence pipeline → Evidence services: collects evidence
- Intelligence pipeline → Generic RAG: retrieves context
- Intelligence pipeline → LLM engine: generates analysis
- Intelligence pipeline → Stock analysis services: scores result
- Intelligence pipeline → Research results: returns analysis
- Data ingestion → Market data providers: fetches market data
- Data ingestion → Platform database: persists ingested data
- Embedding ingestion → Platform database: reads and persists sources
- Embedding ingestion → Stock analysis services: uses embedding ingestion
- Generic RAG → Platform database: retrieves indexed context
- LLM engine → Research results: produces structured output
