How ishan-pngbeep/blue-peak-capital works
1. Repository shape
- This is a split frontend/backend market-intelligence app.
- The main user-facing artifact is a single-page HTML dashboard (index.html at the repo root, plus a frontend/index.html copy in the tree).
- The server side is a small Python FastAPI service in backend/.
2. Frontend boundary
- The browser layer is plain HTML/CSS/JavaScript, not a SPA framework.
- It owns search input, tab switching, chart rendering, and visual presentation of the AI output.
- Its primary integration point is a POST /api/search call to the backend, with CORS enabled so a GitHub Pages-hosted frontend can talk to a Railway-hosted API.
3. Backend orchestration layer
- backend/main.py is the central orchestration point.
- It receives the user’s keyword, coordinates data collection, sends the assembled context to the LLM, and returns structured JSON to the UI.
- It also exposes lighter helper endpoints like prices, macro data, and a waitlist write path.
4. Data ingestion subsystem
- backend/data_sources.py is the fan-out layer to external market sources.
- It fetches from NewsAPI, yFinance, CoinGecko, FRED, and the Fear & Greed index.
- These calls run in parallel and are designed to degrade gracefully: one failing source does not abort the whole request.
5. AI synthesis subsystem
- backend/analyzer.py is the LLM adapter.
- It converts the merged market data into a prompt, instructs Claude to act as a financial analyst, and requires a strict JSON response.
- This is the key transformation boundary: raw market data becomes a structured intelligence report.
6. Core end-to-end data flow
- User enters a keyword in the dashboard.
- Frontend posts it to POST /api/search.
- Backend fetches live data from multiple APIs in parallel.
- Backend passes the merged payload to Claude.
- Claude returns a structured market thesis.
- Frontend renders the result into cards, ripple-chain visuals, charts, and macro indicators.
7. Response contract
- The system is built around a fixed JSON schema from Claude, including sector, trend, confidence, drivers, risks, impacted companies, ripple chain, and forward outlook.
- That contract is important because the frontend is not just dumping text; it expects machine-readable fields to drive multiple visual components.
8. Supplementary API endpoints
- GET /api/prices and GET /api/macro support background market widgets and persistent navbar indicators.
- POST /api/waitlist stores email addresses in Supabase, which is separate from the intelligence request path.
9. Runtime and deployment
- Backend runtime is Python 3.11 with FastAPI/Uvicorn.
- Frontend is static and intended for GitHub Pages.
- Backend hosting is Railway, with API keys and service URLs injected through environment variables rather than shipped to the browser.
10. External systems that materially affect architecture
- Anthropic Claude is the central AI dependency and the expensive part of the request path.
- NewsAPI, yFinance, CoinGecko, FRED, and Fear & Greed are the market data inputs.
- Redis is used as a cache layer to reduce repeated synthesis latency.
- Supabase provides persistent storage for waitlist/user data.
11. Diagram-worthy boundaries
- Browser vs. API server is the primary trust and network boundary.
- Inside the backend, there is a clear split between ingestion (data_sources.py), orchestration (main.py), and synthesis (analyzer.py).
- External APIs are all downstream dependencies of the ingestion layer; Claude is downstream of the merged data payload, not of the browser.
12. Failure and latency characteristics
- The design assumes slow external calls and compensates with parallel fetching and caching.
- Typical latency is dominated by third-party APIs and the Claude call, not by local computation.
- The frontend therefore waits on a single aggregated response rather than streaming partial results.
Main entry points: data_sources.py Data fan-out · main.py Orchestrator · analyzer.py LLM adapter · index.html Dashboard
Components 18
Frontend
Static browser dashboard and UI logic
- Dashboard · Single-page market intelligence UI entrypoint
index.html - UI copy · Secondary dashboard copy in the frontend folder
frontend/index.html - Client logic · Handles search, tab switching, charts, and rendering of structured analysis
- API client · Posts search requests and loads supporting market widgets
Backend
Python API and orchestration layer
- API app · Backend entrypoint serving search, prices, macro, and waitlist routes
backend/main.py - Orchestrator · Coordinates request handling, data collection, caching, and response assembly
backend/main.py - Search API · Main intelligence endpoint for keyword-driven analysis
backend/main.py - Helper APIs · Prices, macro data, and waitlist write paths
backend/main.py - Data fan-out · Parallel market-source collection with graceful degradation
backend/data_sources.py - LLM adapter · Builds analyst prompt and enforces strict JSON market-thesis output
backend/analyzer.py
External systems
Downstream APIs, AI, cache, and storage
- NewsAPI · News and article input for market context
- yFinance · Equity and price-series input
- CoinGecko · Cryptocurrency market input
- FRED · Macroeconomic series input
- Fear & Greed · Market sentiment input
- Claude · Generates structured financial analysis from merged market data
- Redis · Caches repeated synthesis and reduces latency
- Supabase · Persists waitlist and user data
Connections 17
- Dashboard → Client logic: runs · Browser loads and executes dashboard logic
- UI copy → Client logic: mirrors · Alternate static entry serving the same UI behavior
- Client logic → API client: uses · UI actions trigger API requests
- API client → Search API: POST /api/search · Primary keyword analysis request
- API client → Helper APIs: GET/POST helpers · Loads widget data and submits waitlist entries
- Search API → Orchestrator: delegates · Request handling is coordinated centrally
- Orchestrator → Data fan-out: collects data · Fetches live market context in parallel
- Orchestrator → LLM adapter: synthesizes · Sends merged payload for structured analysis
- Orchestrator → Redis: caches · Uses cache to reduce repeated synthesis latency
- Data fan-out → NewsAPI: queries · Retrieves news context
- Data fan-out → yFinance: queries · Retrieves price and ticker data
- Data fan-out → CoinGecko: queries · Retrieves crypto market data
- Data fan-out → FRED: queries · Retrieves macro series
- Data fan-out → Fear & Greed: queries · Retrieves sentiment index
- LLM adapter → Claude: LLM call · Requests analyst-style JSON synthesis
- Helper APIs → Supabase: writes · Stores waitlist submissions
- Orchestrator → API app: served by · Routes are exposed by the FastAPI application