# prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon architecture

> Architecture diagram of the GitHub repository prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon, 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/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon
- Repository: https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon

## Overview

This is a financial-text risk engine with a portfolio stress-testing module and web dashboard. News and StockTwits ingestion store raw documents; the pipeline extracts tracked companies and computes sentiment, event type, and precedent-based impact scores, then stores risk signals. The API exposes signal summaries and runs stress tests for qualifying events; the dashboard presents signals and before/after portfolio results. The README documents the major capabilities; source excerpts show the backend calls. Dashboard-to-API wiring is documented but its implementation is not visible in the sampled page source.

Main entry points: [`src/pipeline.py`](https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/pipeline.py) (Signal pipeline), [`src/api/main.py`](https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/api/main.py) (Risk API), [`src/db/connection.py`](https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/db/connection.py) (Database sessions), [`src/stress_test/trigger.py`](https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/stress_test/trigger.py) (Stress trigger)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Data ingestion"]
  node_news_ingest["News ingestion<br/>[news_ingest.py]"]
  node_social_ingest["Social ingestion"]
end

subgraph group_analysis["Risk analysis"]
  node_pipeline["Signal pipeline<br/>[pipeline.py]"]
  node_sentiment["Sentiment scoring<br/>[sentiment.py]"]
  node_classification["Event classification<br/>[classify.py]"]
  node_impact["Impact scoring<br/>[impact_rag.py]"]
end

subgraph group_storage["Persistence"]
  node_raw_store[("Raw documents<br/>[models.py]")]
  node_signal_store[("Risk signals<br/>[models.py]")]
  node_db_connection["Database sessions<br/>[connection.py]"]
  node_reference_events["Reference events"]
  node_vector_store[("Chroma vectors<br/>[impact_rag.py]")]
end

subgraph group_stress["Portfolio stress"]
  node_trigger["Stress trigger<br/>[trigger.py]"]
  node_portfolio["Portfolio simulation<br/>[portfolio.py]"]
  node_shocks["Asset shocks<br/>[shocks.py]"]
  node_portfolio_data["Synthetic portfolio"]
end

subgraph group_app["API and dashboard"]
  node_api["Risk API<br/>[main.py]"]
  node_dashboard["Risk dashboard<br/>[page.js]"]
end

node_user(("Analyst"))
node_news_source(("News feeds"))
node_social_source(("StockTwits"))

node_news_source -->|"provides feeds"| node_news_ingest
node_social_source -->|"provides messages"| node_social_ingest
node_news_ingest -->|"opens session"| node_db_connection
node_social_ingest -->|"opens session"| node_db_connection
node_news_ingest -->|"inserts documents"| node_raw_store
node_social_ingest -->|"inserts documents"| node_raw_store
node_pipeline -->|"opens session"| node_db_connection
node_pipeline -->|"reads documents"| node_raw_store
node_pipeline -->|"scores sentiment"| node_sentiment
node_pipeline -->|"classifies events"| node_classification
node_pipeline -->|"scores impact"| node_impact
node_pipeline -->|"writes signals"| node_signal_store
node_impact -->|"loads precedents"| node_reference_events
node_impact -->|"queries vectors"| node_vector_store
node_api -->|"opens session"| node_db_connection
node_api -->|"queries signals"| node_signal_store
node_user -->|"requests results"| node_api
node_dashboard -.->|"fetches results"| node_api
node_user -->|"views results"| node_dashboard
node_api -->|"runs stress tests"| node_trigger
node_trigger -->|"opens session"| node_db_connection
node_trigger -->|"filters signals"| node_signal_store
node_trigger -->|"runs simulation"| node_portfolio
node_portfolio -->|"loads assets"| node_portfolio_data
node_portfolio -->|"gets shocks"| node_shocks

click node_news_ingest "https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/ingestion/news_ingest.py"
click node_social_ingest "https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/ingestion/stocktwits_ingest.py"
click node_pipeline "https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/pipeline.py"
click node_sentiment "https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/nlp/sentiment.py"
click node_classification "https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/nlp/classify.py"
click node_impact "https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/nlp/impact_rag.py"
click node_raw_store "https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/db/models.py"
click node_signal_store "https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/db/models.py"
click node_db_connection "https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/db/connection.py"
click node_reference_events "https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/data/reference_events.json"
click node_vector_store "https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/nlp/impact_rag.py"
click node_api "https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/api/main.py"
click node_dashboard "https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/dashboard/app/page.js"
click node_trigger "https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/stress_test/trigger.py"
click node_portfolio "https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/stress_test/portfolio.py"
click node_shocks "https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/stress_test/shocks.py"
click node_portfolio_data "https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/data/synthetic_portfolio.json"

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_news_ingest,node_social_ingest toneBlue
class node_pipeline,node_sentiment,node_classification,node_impact toneAmber
class node_raw_store,node_signal_store,node_db_connection,node_reference_events,node_vector_store toneMint
class node_trigger,node_portfolio,node_shocks,node_portfolio_data toneRose
class node_api,node_dashboard,node_user,node_news_source,node_social_source toneIndigo
```

## Components

### Data ingestion

- [News ingestion](https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/ingestion/news_ingest.py): `src/ingestion/news_ingest.py`
- [Social ingestion](https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/ingestion/stocktwits_ingest.py): `src/ingestion/stocktwits_ingest.py`

### Risk analysis

- [Signal pipeline](https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/pipeline.py): `src/pipeline.py`
- [Sentiment scoring](https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/nlp/sentiment.py): `src/nlp/sentiment.py`
- [Event classification](https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/nlp/classify.py): `src/nlp/classify.py`
- [Impact scoring](https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/nlp/impact_rag.py): `src/nlp/impact_rag.py`

### Persistence

- [Raw documents](https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/db/models.py): `src/db/models.py`
- [Risk signals](https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/db/models.py): `src/db/models.py`
- [Database sessions](https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/db/connection.py): `src/db/connection.py`
- [Reference events](https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/data/reference_events.json): `data/reference_events.json`
- [Chroma vectors](https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/nlp/impact_rag.py): `src/nlp/impact_rag.py`

### Portfolio stress

- [Stress trigger](https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/stress_test/trigger.py): `src/stress_test/trigger.py`
- [Portfolio simulation](https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/stress_test/portfolio.py): `src/stress_test/portfolio.py`
- [Asset shocks](https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/stress_test/shocks.py): `src/stress_test/shocks.py`
- [Synthetic portfolio](https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/data/synthetic_portfolio.json): `data/synthetic_portfolio.json`

### API and dashboard

- [Risk API](https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/src/api/main.py): `src/api/main.py`
- [Risk dashboard](https://github.com/prateeknitcse/national-institute-of-technology-arunachal-pradesh-prateek-singh-hackathon/blob/main/dashboard/app/page.js): `dashboard/app/page.js`

### Other components

- **Analyst**
- **News feeds**
- **StockTwits**

## Connections

- News feeds → News ingestion: provides feeds (evidence: `src/ingestion/news_ingest.py`)
- StockTwits → Social ingestion: provides messages (evidence: `src/ingestion/stocktwits_ingest.py`)
- News ingestion → Database sessions: opens session (evidence: `src/ingestion/news_ingest.py`)
- Social ingestion → Database sessions: opens session (evidence: `src/ingestion/stocktwits_ingest.py`)
- News ingestion → Raw documents: inserts documents (evidence: `src/ingestion/news_ingest.py`)
- Social ingestion → Raw documents: inserts documents (evidence: `src/ingestion/stocktwits_ingest.py`)
- Signal pipeline → Database sessions: opens session (evidence: `src/pipeline.py`)
- Signal pipeline → Raw documents: reads documents (evidence: `src/pipeline.py`)
- Signal pipeline → Sentiment scoring: scores sentiment (evidence: `src/pipeline.py`)
- Signal pipeline → Event classification: classifies events (evidence: `src/pipeline.py`)
- Signal pipeline → Impact scoring: scores impact (evidence: `src/pipeline.py`)
- Signal pipeline → Risk signals: writes signals (evidence: `src/pipeline.py`)
- Impact scoring → Reference events: loads precedents (evidence: `src/nlp/impact_rag.py`)
- Impact scoring → Chroma vectors: queries vectors (evidence: `src/nlp/impact_rag.py`)
- Risk API → Database sessions: opens session (evidence: `src/api/main.py`)
- Risk API → Risk signals: queries signals (evidence: `src/api/main.py`)
- Analyst → Risk API: requests results (evidence: `README.md`)
- Risk dashboard → Risk API: fetches results (evidence: `README.md`)
- Analyst → Risk dashboard: views results (evidence: `README.md`)
- Risk API → Stress trigger: runs stress tests (evidence: `src/api/main.py`)
- Stress trigger → Database sessions: opens session (evidence: `src/stress_test/trigger.py`)
- Stress trigger → Risk signals: filters signals (evidence: `src/stress_test/trigger.py`)
- Stress trigger → Portfolio simulation: runs simulation (evidence: `src/stress_test/trigger.py`)
- Portfolio simulation → Synthetic portfolio: loads assets (evidence: `src/stress_test/portfolio.py`)
- Portfolio simulation → Asset shocks: gets shocks (evidence: `src/stress_test/portfolio.py`)
