# sarinasharif21/financial-news-ai architecture

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

- Interactive diagram: https://gitdiagram.com/sarinasharif21/financial-news-ai
- Repository: https://github.com/sarinasharif21/financial-news-ai

## Overview

This repository is a command-line financial-news analysis application. A user enters an article; the runtime preprocesses it for Reuters classification, then checks the predicted topic. Only selected financially important categories trigger IMDB-tokenized sentiment analysis and a Buy/Sell label; other categories produce an Indirect result. The graph distinguishes those domain stages from model and tokenizer assets. Training capabilities are documented in notebooks, but the only indexed runtime source is src/predict.py, so unsampled training details and links are not expanded.

Main entry points: [`src/predict.py`](https://github.com/sarinasharif21/financial-news-ai/blob/main/src/predict.py) (CLI entry), [`models/sentiment_model.h5`](https://github.com/sarinasharif21/financial-news-ai/blob/main/models/sentiment_model.h5) (Sentiment classifier), [`models/reuters_category_model.h5`](https://github.com/sarinasharif21/financial-news-ai/blob/main/models/reuters_category_model.h5) (Category classifier), [`models/tokenizer.pickle`](https://github.com/sarinasharif21/financial-news-ai/blob/main/models/tokenizer.pickle) (Sentiment tokenizer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analysis["News analysis"]
  node_cli["CLI entry<br/>[predict.py]"]
  node_category_prep["Reuters preprocessing<br/>[predict.py]"]
  node_category_model["Category classifier"]
  node_topic_gate["Topic relevance gate<br/>[predict.py]"]
  node_sentiment_prep["Sentiment preprocessing<br/>[predict.py]"]
  node_sentiment_model["Sentiment classifier<br/>[sentiment_model.h5]"]
  node_decision["Suggestion decision<br/>[predict.py]"]
end

subgraph group_assets["Model assets"]
  node_tokenizer["Sentiment tokenizer<br/>[tokenizer.pickle]"]
  node_reuters_data[("Reuters word index")]
end

node_user(("News user"))

node_user -->|"enters article"| node_cli
node_cli -->|"preprocesses text"| node_category_prep
node_category_prep -->|"classifies sequence"| node_category_model
node_category_prep -->|"looks up words"| node_reuters_data
node_cli -->|"checks category"| node_topic_gate
node_topic_gate -->|"routes relevant text"| node_sentiment_prep
node_sentiment_prep -->|"tokenizes text"| node_tokenizer
node_sentiment_prep -->|"prepares sequence"| node_sentiment_model
node_topic_gate -->|"sets indirect result"| node_decision
node_sentiment_model -->|"provides sentiment"| node_decision
node_cli -->|"prints analysis"| node_user

click node_cli "https://github.com/sarinasharif21/financial-news-ai/blob/main/src/predict.py"
click node_category_prep "https://github.com/sarinasharif21/financial-news-ai/blob/main/src/predict.py"
click node_category_model "https://github.com/sarinasharif21/financial-news-ai/blob/main/models/reuters_category_model.h5"
click node_topic_gate "https://github.com/sarinasharif21/financial-news-ai/blob/main/src/predict.py"
click node_sentiment_prep "https://github.com/sarinasharif21/financial-news-ai/blob/main/src/predict.py"
click node_sentiment_model "https://github.com/sarinasharif21/financial-news-ai/blob/main/models/sentiment_model.h5"
click node_decision "https://github.com/sarinasharif21/financial-news-ai/blob/main/src/predict.py"
click node_tokenizer "https://github.com/sarinasharif21/financial-news-ai/blob/main/models/tokenizer.pickle"

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_cli,node_category_prep,node_category_model,node_topic_gate,node_sentiment_prep,node_sentiment_model,node_decision,node_user toneBlue
class node_tokenizer,node_reuters_data toneAmber
```

## Components

### News analysis

- [CLI entry](https://github.com/sarinasharif21/financial-news-ai/blob/main/src/predict.py): `src/predict.py`
- [Reuters preprocessing](https://github.com/sarinasharif21/financial-news-ai/blob/main/src/predict.py): `src/predict.py`
- [Category classifier](https://github.com/sarinasharif21/financial-news-ai/blob/main/models/reuters_category_model.h5): `models/reuters_category_model.h5`
- [Topic relevance gate](https://github.com/sarinasharif21/financial-news-ai/blob/main/src/predict.py): `src/predict.py`
- [Sentiment preprocessing](https://github.com/sarinasharif21/financial-news-ai/blob/main/src/predict.py): `src/predict.py`
- [Sentiment classifier](https://github.com/sarinasharif21/financial-news-ai/blob/main/models/sentiment_model.h5): `models/sentiment_model.h5`
- [Suggestion decision](https://github.com/sarinasharif21/financial-news-ai/blob/main/src/predict.py): `src/predict.py`

### Model assets

- [Sentiment tokenizer](https://github.com/sarinasharif21/financial-news-ai/blob/main/models/tokenizer.pickle): `models/tokenizer.pickle`
- **Reuters word index**

### Other components

- **News user**

## Connections

- News user → CLI entry: enters article (evidence: `README.md`)
- CLI entry → Reuters preprocessing: preprocesses text (evidence: `src/predict.py`)
- Reuters preprocessing → Category classifier: classifies sequence (evidence: `src/predict.py`)
- Reuters preprocessing → Reuters word index: looks up words (evidence: `src/predict.py`)
- CLI entry → Topic relevance gate: checks category (evidence: `src/predict.py`)
- Topic relevance gate → Sentiment preprocessing: routes relevant text (evidence: `README.md`)
- Sentiment preprocessing → Sentiment tokenizer: tokenizes text (evidence: `src/predict.py`)
- Sentiment preprocessing → Sentiment classifier: prepares sequence (evidence: `src/predict.py`)
- Topic relevance gate → Suggestion decision: sets indirect result (evidence: `src/predict.py`)
- Sentiment classifier → Suggestion decision: provides sentiment (evidence: `src/predict.py`)
- CLI entry → News user: prints analysis (evidence: `src/predict.py`)
