# mithleshy885/stock-prediction-portal architecture

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

- Interactive diagram: https://gitdiagram.com/mithleshy885/stock-prediction-portal
- Repository: https://github.com/mithleshy885/stock-prediction-portal

## Overview

This repository implements a stock-prediction portal: a React frontend supports account registration and login, then exposes a protected dashboard; a Django REST backend provides account/token endpoints and a stock-prediction endpoint. The prediction handler fetches market history, generates chart outputs, runs a bundled Keras model, and returns prediction metrics. The frontend dashboard currently calls the protected-data endpoint, not the prediction endpoint. Several frontend and backend relationships are explicit in the sampled files; unsampled wiring is not inferred.

Main entry points: [`frontend-react/src/App.jsx`](https://github.com/mithleshy885/stock-prediction-portal/blob/main/frontend-react/src/App.jsx) (Routes and layout), [`backend-drf/api/views.py`](https://github.com/mithleshy885/stock-prediction-portal/blob/main/backend-drf/api/views.py) (Prediction handler), [`backend-drf/api/urls.py`](https://github.com/mithleshy885/stock-prediction-portal/blob/main/backend-drf/api/urls.py) (API routes), [`frontend-react/src/components/Login.jsx`](https://github.com/mithleshy885/stock-prediction-portal/blob/main/frontend-react/src/components/Login.jsx) (Login form)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React frontend"]
  node_entry["React entry<br/>[main.jsx]"]
  node_app["Routes and layout<br/>[App.jsx]"]
  node_authstate["Auth state<br/>[AuthProvider.jsx]"]
  node_routeguards["Route guards<br/>[PrivateRoute.jsx]"]
  node_registerform["Registration form<br/>[Register.jsx]"]
  node_loginform["Login form<br/>[Login.jsx]"]
  node_header["Account navigation<br/>[Header.jsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_httpclient["HTTP client<br/>[axiosInstance.js]"]
end

subgraph group_accounts["Accounts and access"]
  node_backendroutes["API routes<br/>[urls.py]"]
  node_registerapi["Registration API<br/>[views.py]"]
  node_userserializer["User serializer<br/>[serializers.py]"]
  node_userstore[("User records<br/>[serializers.py]")]
  node_protectedapi["Protected API<br/>[views.py]"]
  node_tokenservice["JWT token endpoints<br/>[urls.py]"]
end

subgraph group_prediction["Stock prediction"]
  node_predictionapi["Prediction handler<br/>[views.py]"]
  node_marketdata["Market history"]
  node_modelartifact["Keras model"]
  node_plothelper["Plot saving<br/>[utils.py]"]
end

node_visitor(("Portal user"))
node_marketservice["Yahoo Finance"]

node_visitor -->|"opens portal"| node_entry
node_entry -->|"renders"| node_app
node_app -->|"wraps routes"| node_authstate
node_app -->|"routes to"| node_registerform
node_app -->|"routes to"| node_loginform
node_app -->|"routes to"| node_dashboard
node_app -->|"guards routes"| node_routeguards
node_loginform -->|"updates login"| node_authstate
node_header -->|"reads state"| node_authstate
node_registerform -->|"posts registration"| node_backendroutes
node_loginform -->|"requests tokens"| node_tokenservice
node_dashboard -->|"calls through"| node_httpclient
node_dashboard -->|"requests protected data"| node_protectedapi
node_backendroutes -->|"routes registration"| node_registerapi
node_backendroutes -->|"routes protected view"| node_protectedapi
node_backendroutes -->|"registers token routes"| node_tokenservice
node_registerapi -->|"serializes users"| node_userserializer
node_userserializer -->|"creates user"| node_userstore
node_predictionapi -->|"downloads history"| node_marketservice
node_predictionapi -->|"processes prices"| node_marketdata
node_predictionapi -->|"loads and predicts"| node_modelartifact
node_predictionapi -->|"saves charts"| node_plothelper

click node_entry "https://github.com/mithleshy885/stock-prediction-portal/blob/main/frontend-react/src/main.jsx"
click node_app "https://github.com/mithleshy885/stock-prediction-portal/blob/main/frontend-react/src/App.jsx"
click node_authstate "https://github.com/mithleshy885/stock-prediction-portal/blob/main/frontend-react/src/AuthProvider.jsx"
click node_routeguards "https://github.com/mithleshy885/stock-prediction-portal/blob/main/frontend-react/src/PrivateRoute.jsx"
click node_registerform "https://github.com/mithleshy885/stock-prediction-portal/blob/main/frontend-react/src/components/Register.jsx"
click node_loginform "https://github.com/mithleshy885/stock-prediction-portal/blob/main/frontend-react/src/components/Login.jsx"
click node_header "https://github.com/mithleshy885/stock-prediction-portal/blob/main/frontend-react/src/components/Header.jsx"
click node_dashboard "https://github.com/mithleshy885/stock-prediction-portal/blob/main/frontend-react/src/components/dashboard/Dashboard.jsx"
click node_httpclient "https://github.com/mithleshy885/stock-prediction-portal/blob/main/frontend-react/src/axiosInstance.js"
click node_backendroutes "https://github.com/mithleshy885/stock-prediction-portal/blob/main/backend-drf/api/urls.py"
click node_registerapi "https://github.com/mithleshy885/stock-prediction-portal/blob/main/backend-drf/accounts/views.py"
click node_userserializer "https://github.com/mithleshy885/stock-prediction-portal/blob/main/backend-drf/accounts/serializers.py"
click node_userstore "https://github.com/mithleshy885/stock-prediction-portal/blob/main/backend-drf/accounts/serializers.py"
click node_protectedapi "https://github.com/mithleshy885/stock-prediction-portal/blob/main/backend-drf/accounts/views.py"
click node_tokenservice "https://github.com/mithleshy885/stock-prediction-portal/blob/main/backend-drf/api/urls.py"
click node_predictionapi "https://github.com/mithleshy885/stock-prediction-portal/blob/main/backend-drf/api/views.py"
click node_modelartifact "https://github.com/mithleshy885/stock-prediction-portal/blob/main/backend-drf/stock_prediction_model.keras"
click node_plothelper "https://github.com/mithleshy885/stock-prediction-portal/blob/main/backend-drf/api/utils.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_entry,node_app,node_authstate,node_routeguards,node_registerform,node_loginform,node_header,node_dashboard,node_httpclient,node_visitor toneBlue
class node_backendroutes,node_registerapi,node_userserializer,node_userstore,node_protectedapi,node_tokenservice toneAmber
class node_predictionapi,node_marketdata,node_modelartifact,node_plothelper toneMint
class node_marketservice toneIndigo
```

## Components

### React frontend

- [React entry](https://github.com/mithleshy885/stock-prediction-portal/blob/main/frontend-react/src/main.jsx): `frontend-react/src/main.jsx`
- [Routes and layout](https://github.com/mithleshy885/stock-prediction-portal/blob/main/frontend-react/src/App.jsx): `frontend-react/src/App.jsx`
- [Auth state](https://github.com/mithleshy885/stock-prediction-portal/blob/main/frontend-react/src/AuthProvider.jsx): `frontend-react/src/AuthProvider.jsx`
- [Route guards](https://github.com/mithleshy885/stock-prediction-portal/blob/main/frontend-react/src/PrivateRoute.jsx): `frontend-react/src/PrivateRoute.jsx`
- [Registration form](https://github.com/mithleshy885/stock-prediction-portal/blob/main/frontend-react/src/components/Register.jsx): `frontend-react/src/components/Register.jsx`
- [Login form](https://github.com/mithleshy885/stock-prediction-portal/blob/main/frontend-react/src/components/Login.jsx): `frontend-react/src/components/Login.jsx`
- [Account navigation](https://github.com/mithleshy885/stock-prediction-portal/blob/main/frontend-react/src/components/Header.jsx): `frontend-react/src/components/Header.jsx`
- [Dashboard](https://github.com/mithleshy885/stock-prediction-portal/blob/main/frontend-react/src/components/dashboard/Dashboard.jsx): `frontend-react/src/components/dashboard/Dashboard.jsx`
- [HTTP client](https://github.com/mithleshy885/stock-prediction-portal/blob/main/frontend-react/src/axiosInstance.js): `frontend-react/src/axiosInstance.js`

### Accounts and access

- [API routes](https://github.com/mithleshy885/stock-prediction-portal/blob/main/backend-drf/api/urls.py): `backend-drf/api/urls.py`
- [Registration API](https://github.com/mithleshy885/stock-prediction-portal/blob/main/backend-drf/accounts/views.py): `backend-drf/accounts/views.py`
- [User serializer](https://github.com/mithleshy885/stock-prediction-portal/blob/main/backend-drf/accounts/serializers.py): `backend-drf/accounts/serializers.py`
- [User records](https://github.com/mithleshy885/stock-prediction-portal/blob/main/backend-drf/accounts/serializers.py): `backend-drf/accounts/serializers.py`
- [Protected API](https://github.com/mithleshy885/stock-prediction-portal/blob/main/backend-drf/accounts/views.py): `backend-drf/accounts/views.py`
- [JWT token endpoints](https://github.com/mithleshy885/stock-prediction-portal/blob/main/backend-drf/api/urls.py): `backend-drf/api/urls.py`

### Stock prediction

- [Prediction handler](https://github.com/mithleshy885/stock-prediction-portal/blob/main/backend-drf/api/views.py): `backend-drf/api/views.py`
- **Market history**
- [Keras model](https://github.com/mithleshy885/stock-prediction-portal/blob/main/backend-drf/stock_prediction_model.keras): `backend-drf/stock_prediction_model.keras`
- [Plot saving](https://github.com/mithleshy885/stock-prediction-portal/blob/main/backend-drf/api/utils.py): `backend-drf/api/utils.py`

### Other components

- **Portal user**
- **Yahoo Finance**

## Connections

- Portal user → React entry: opens portal (evidence: `frontend-react/src/main.jsx`)
- React entry → Routes and layout: renders (evidence: `frontend-react/src/main.jsx`)
- Routes and layout → Auth state: wraps routes (evidence: `frontend-react/src/App.jsx`)
- Routes and layout → Registration form: routes to (evidence: `frontend-react/src/App.jsx`)
- Routes and layout → Login form: routes to (evidence: `frontend-react/src/App.jsx`)
- Routes and layout → Dashboard: routes to (evidence: `frontend-react/src/App.jsx`)
- Routes and layout → Route guards: guards routes (evidence: `frontend-react/src/App.jsx`)
- Login form → Auth state: updates login (evidence: `frontend-react/src/components/Login.jsx`)
- Account navigation → Auth state: reads state (evidence: `frontend-react/src/components/Header.jsx`)
- Registration form → API routes: posts registration (evidence: `frontend-react/src/components/Register.jsx`)
- Login form → JWT token endpoints: requests tokens (evidence: `frontend-react/src/components/Login.jsx`)
- Dashboard → HTTP client: calls through (evidence: `frontend-react/src/components/dashboard/Dashboard.jsx`)
- Dashboard → Protected API: requests protected data (evidence: `frontend-react/src/components/dashboard/Dashboard.jsx`)
- API routes → Registration API: routes registration (evidence: `backend-drf/api/urls.py`)
- API routes → Protected API: routes protected view (evidence: `backend-drf/api/urls.py`)
- API routes → JWT token endpoints: registers token routes (evidence: `backend-drf/api/urls.py`)
- Registration API → User serializer: serializes users (evidence: `backend-drf/accounts/views.py`)
- User serializer → User records: creates user (evidence: `backend-drf/accounts/serializers.py`)
- Prediction handler → Yahoo Finance: downloads history (evidence: `backend-drf/api/views.py`)
- Prediction handler → Market history: processes prices (evidence: `backend-drf/api/views.py`)
- Prediction handler → Keras model: loads and predicts (evidence: `backend-drf/api/views.py`)
- Prediction handler → Plot saving: saves charts (evidence: `backend-drf/api/views.py`)
