# mehassanhmood/portfolio-optimzation architecture

> Architecture diagram of the GitHub repository mehassanhmood/portfolio-optimzation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mehassanhmood/portfolio-optimzation
- Repository: https://github.com/mehassanhmood/portfolio-optimzation

## Overview

This repository combines a small Flask sentiment-analysis demo with a broader stock-market research project. The principal runtime workflow is a user entering text in the web page, the browser requesting analysis from Flask, and the server returning a FinBERT classification. The README also describes data collection, model development and evaluation, quantitative-data integration, and prediction goals; those research capabilities are represented at the level supported by the README and file tree. The notebook and dataset were not sampled, so their internal behavior is not inferred.

Main entry points: [`downstram-pipeline/server.py`](https://github.com/mehassanhmood/portfolio-optimzation/blob/main/downstram-pipeline/server.py) (Flask Server), [`main.ipynb`](https://github.com/mehassanhmood/portfolio-optimzation/blob/main/main.ipynb) (Model Experiments), [`downstram-pipeline/templates/index.html`](https://github.com/mehassanhmood/portfolio-optimzation/blob/main/downstram-pipeline/templates/index.html) (Analysis Page), [`all-data.csv`](https://github.com/mehassanhmood/portfolio-optimzation/blob/main/all-data.csv) (Market Sentiment Data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web_app["Sentiment Web App"]
  node_web_page["Analysis Page<br/>[index.html]"]
  node_browser_script["Browser Request<br/>[mywebscript.js]"]
  node_flask_server["Flask Server<br/>[server.py]"]
  node_classifier["FinBERT Classifier"]
end

subgraph group_research["Model Research"]
  node_research_notebook["Model Experiments<br/>[main.ipynb]"]
  node_market_predictions["Market Prediction<br/>[main.ipynb]"]
  node_evaluation["Model Evaluation<br/>[main.ipynb]"]
end

subgraph group_data["Data Inputs"]
  node_market_data[("Market Sentiment Data<br/>[all-data.csv]")]
end

node_user(("User"))
node_fmp{{"FMP API"}}
node_kaggle{{"Kaggle"}}

node_user -.->|"enters text"| node_web_page
node_web_page -.->|"runs script"| node_browser_script
node_browser_script -->|"requests analysis"| node_flask_server
node_flask_server -->|"renders page"| node_web_page
node_flask_server -->|"calls analyzer"| node_classifier
node_classifier -->|"returns labels"| node_flask_server
node_fmp -.->|"provides sentiment data"| node_market_data
node_kaggle -.->|"provides training data"| node_market_data
node_market_data -.->|"supports analysis"| node_research_notebook
node_research_notebook -.->|"evaluates models"| node_evaluation
node_research_notebook -.->|"develops predictions"| node_market_predictions

click node_web_page "https://github.com/mehassanhmood/portfolio-optimzation/blob/main/downstram-pipeline/templates/index.html"
click node_browser_script "https://github.com/mehassanhmood/portfolio-optimzation/blob/main/downstram-pipeline/static/mywebscript.js"
click node_flask_server "https://github.com/mehassanhmood/portfolio-optimzation/blob/main/downstram-pipeline/server.py"
click node_classifier "https://github.com/mehassanhmood/portfolio-optimzation/blob/main/downstram-pipeline/SentimentAnalysis/sentiment_analysis.py"
click node_research_notebook "https://github.com/mehassanhmood/portfolio-optimzation/blob/main/main.ipynb"
click node_market_predictions "https://github.com/mehassanhmood/portfolio-optimzation/blob/main/main.ipynb"
click node_evaluation "https://github.com/mehassanhmood/portfolio-optimzation/blob/main/main.ipynb"
click node_market_data "https://github.com/mehassanhmood/portfolio-optimzation/blob/main/all-data.csv"

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_web_page,node_browser_script,node_flask_server,node_classifier,node_user toneBlue
class node_research_notebook,node_market_predictions,node_evaluation toneAmber
class node_market_data,node_fmp toneMint
class node_kaggle toneIndigo
```

## Components

### Sentiment Web App

- [Analysis Page](https://github.com/mehassanhmood/portfolio-optimzation/blob/main/downstram-pipeline/templates/index.html): `downstram-pipeline/templates/index.html`
- [Browser Request](https://github.com/mehassanhmood/portfolio-optimzation/blob/main/downstram-pipeline/static/mywebscript.js): `downstram-pipeline/static/mywebscript.js`
- [Flask Server](https://github.com/mehassanhmood/portfolio-optimzation/blob/main/downstram-pipeline/server.py): `downstram-pipeline/server.py`
- [FinBERT Classifier](https://github.com/mehassanhmood/portfolio-optimzation/blob/main/downstram-pipeline/SentimentAnalysis/sentiment_analysis.py): `downstram-pipeline/SentimentAnalysis/sentiment_analysis.py`

### Model Research

- [Model Experiments](https://github.com/mehassanhmood/portfolio-optimzation/blob/main/main.ipynb): `main.ipynb`
- [Market Prediction](https://github.com/mehassanhmood/portfolio-optimzation/blob/main/main.ipynb): `main.ipynb`
- [Model Evaluation](https://github.com/mehassanhmood/portfolio-optimzation/blob/main/main.ipynb): `main.ipynb`

### Data Inputs

- [Market Sentiment Data](https://github.com/mehassanhmood/portfolio-optimzation/blob/main/all-data.csv): `all-data.csv`

### Other components

- **User**
- **FMP API**
- **Kaggle**

## Connections

- User → Analysis Page: enters text
- Analysis Page → Browser Request: runs script
- Browser Request → Flask Server: requests analysis (evidence: `downstram-pipeline/static/mywebscript.js`)
- Flask Server → Analysis Page: renders page (evidence: `downstram-pipeline/server.py`)
- Flask Server → FinBERT Classifier: calls analyzer (evidence: `downstram-pipeline/server.py`)
- FinBERT Classifier → Flask Server: returns labels (evidence: `downstram-pipeline/server.py`)
- FMP API → Market Sentiment Data: provides sentiment data (evidence: `README.md`)
- Kaggle → Market Sentiment Data: provides training data (evidence: `README.md`)
- Market Sentiment Data → Model Experiments: supports analysis (evidence: `README.md`)
- Model Experiments → Model Evaluation: evaluates models (evidence: `README.md`)
- Model Experiments → Market Prediction: develops predictions (evidence: `README.md`)
