# subha2707/priceoracle architecture

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

- Interactive diagram: https://gitdiagram.com/subha2707/priceoracle
- Repository: https://github.com/subha2707/priceoracle

## Overview

PriceOracle lets users browse multi-asset prices and predictions, then access analytics and personal features such as watchlists, alerts, and account settings. The React app calls an Express API backed by MongoDB; a Python ML service supplies prices and predictions. The README documents the ML pipeline stages, while sampled backend code confirms price synchronization, scheduled prediction persistence, and Socket.IO updates. Some client-to-server and unsampled page interactions are not shown, so those links are omitted or marked unverified.

Main entry points: [`client/src/App.jsx`](https://github.com/subha2707/priceoracle/blob/main/client/src/App.jsx) (Web routes), [`server/app.js`](https://github.com/subha2707/priceoracle/blob/main/server/app.js) (API application), [`server/server.js`](https://github.com/subha2707/priceoracle/blob/main/server/server.js) (Socket.IO server), [`server/routes/predictions.js`](https://github.com/subha2707/priceoracle/blob/main/server/routes/predictions.js) (Prediction endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_app["Web routes<br/>[App.jsx]"]
  node_authui["Account flows<br/>[AuthContext.jsx]"]
  node_dashboard["Prices dashboard<br/>[Dashboard.jsx]"]
  node_analytics["Analytics views<br/>[Analytics.jsx]"]
  node_predviews["Predictions views<br/>[Predictions.jsx]"]
  node_watchlist["Watchlist<br/>[Watchlist.jsx]"]
  node_assetdetail["Asset detail<br/>[AssetDetail.jsx]"]
  node_api["HTTP client<br/>[axios.js]"]
end

subgraph group_backend["API and services"]
  node_express["API application<br/>[app.js]"]
  node_authroutes["Authentication<br/>[auth.js]"]
  node_assetroutes["Asset endpoints<br/>[assets.js]"]
  node_predroutes["Prediction endpoints<br/>[predictions.js]"]
  node_useroutes["User endpoints<br/>[user.js]"]
  node_alertroutes["Alert endpoints<br/>[alerts.js]"]
  node_pricesvc["Price service<br/>[priceService.js]"]
  node_runner["Prediction scheduler"]
  node_alertsjob["Alert checker<br/>[alertChecker.js]"]
  node_authmw["Token middleware<br/>[auth.js]"]
  node_mlbridge["ML API bridge<br/>[mlBridge.js]"]
end

subgraph group_data["Market data and ML"]
  node_collector["Market collection<br/>[data_collection.py]"]
  node_sentiment["Sentiment analysis"]
  node_preprocess["Preprocessing<br/>[preprocessing.py]"]
  node_training["Model training<br/>[train_model.py]"]
  node_mlapi["Prediction API<br/>[api_server.py]"]
end

subgraph group_storage["Persistent data"]
  node_db[("MongoDB<br/>[db.js]")]
  node_users[("User records<br/>[User.js]")]
  node_assets[("Asset records<br/>[Asset.js]")]
  node_predictions[("Prediction records<br/>[Prediction.js]")]
  node_alerts[("Alert records<br/>[Alert.js]")]
end

subgraph group_realtime["Live updates"]
  node_socketserver["Socket.IO server<br/>[server.js]"]
  node_socketclient["Live client<br/>[SocketContext.jsx]"]
end

node_user(("Investor"))
node_market(("Market data sources"))

node_user -->|"browses"| node_app
node_app -->|"provides auth"| node_authui
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_analytics
node_app -->|"routes to"| node_predviews
node_app -->|"routes to"| node_watchlist
node_app -->|"routes to"| node_assetdetail
node_authui -->|"calls"| node_api
node_dashboard -->|"requests data"| node_api
node_api -.->|"HTTP requests"| node_express
node_express -->|"mounts"| node_authroutes
node_express -->|"mounts"| node_assetroutes
node_express -->|"mounts"| node_predroutes
node_express -->|"mounts"| node_alertroutes
node_express -->|"mounts"| node_useroutes
node_authroutes -->|"reads and writes"| node_users
node_authroutes -->|"uses OTP records"| node_alerts
node_authroutes -->|"protects logout"| node_authmw
node_authmw -->|"loads user"| node_users
node_predroutes -->|"authenticates"| node_authmw
node_predroutes -->|"reads and writes"| node_predictions
node_predroutes -->|"reads assets"| node_assets
node_predroutes -->|"requests predictions"| node_mlbridge
node_useroutes -->|"authenticates"| node_authmw
node_useroutes -->|"updates profile"| node_users
node_useroutes -->|"accesses assets"| node_assets
node_alertroutes -->|"authenticates"| node_authmw
node_alertroutes -->|"manages alerts"| node_alerts
node_pricesvc -->|"fetches prices"| node_mlbridge
node_pricesvc -->|"updates assets"| node_assets
node_runner -->|"fetches predictions"| node_mlbridge
node_runner -->|"saves predictions"| node_predictions
node_socketserver -->|"starts sync"| node_pricesvc
node_socketserver -->|"starts job"| node_runner
node_socketserver -->|"starts checker"| node_alertsjob
node_socketclient -.->|"joins live rooms"| node_socketserver
node_market -.->|"supplies data"| node_collector
node_collector -->|"pipeline stage"| node_sentiment
node_sentiment -->|"pipeline stage"| node_preprocess
node_preprocess -->|"pipeline stage"| node_training
node_training -.->|"serves models"| node_mlapi
node_mlapi -->|"provides ML API"| node_mlbridge
node_socketserver -.->|"pushes updates"| node_socketclient
node_socketserver -->|"connects"| node_db

click node_app "https://github.com/subha2707/priceoracle/blob/main/client/src/App.jsx"
click node_authui "https://github.com/subha2707/priceoracle/blob/main/client/src/context/AuthContext.jsx"
click node_dashboard "https://github.com/subha2707/priceoracle/blob/main/client/src/pages/Dashboard.jsx"
click node_analytics "https://github.com/subha2707/priceoracle/blob/main/client/src/pages/Analytics.jsx"
click node_predviews "https://github.com/subha2707/priceoracle/blob/main/client/src/pages/Predictions.jsx"
click node_watchlist "https://github.com/subha2707/priceoracle/blob/main/client/src/pages/Watchlist.jsx"
click node_assetdetail "https://github.com/subha2707/priceoracle/blob/main/client/src/pages/AssetDetail.jsx"
click node_api "https://github.com/subha2707/priceoracle/blob/main/client/src/api/axios.js"
click node_express "https://github.com/subha2707/priceoracle/blob/main/server/app.js"
click node_authroutes "https://github.com/subha2707/priceoracle/blob/main/server/routes/auth.js"
click node_assetroutes "https://github.com/subha2707/priceoracle/blob/main/server/routes/assets.js"
click node_predroutes "https://github.com/subha2707/priceoracle/blob/main/server/routes/predictions.js"
click node_useroutes "https://github.com/subha2707/priceoracle/blob/main/server/routes/user.js"
click node_alertroutes "https://github.com/subha2707/priceoracle/blob/main/server/routes/alerts.js"
click node_pricesvc "https://github.com/subha2707/priceoracle/blob/main/server/services/priceService.js"
click node_runner "https://github.com/subha2707/priceoracle/blob/main/server/jobs/predictionRunner.js"
click node_alertsjob "https://github.com/subha2707/priceoracle/blob/main/server/jobs/alertChecker.js"
click node_authmw "https://github.com/subha2707/priceoracle/blob/main/server/middleware/auth.js"
click node_mlbridge "https://github.com/subha2707/priceoracle/blob/main/server/services/mlBridge.js"
click node_db "https://github.com/subha2707/priceoracle/blob/main/server/config/db.js"
click node_users "https://github.com/subha2707/priceoracle/blob/main/server/models/User.js"
click node_assets "https://github.com/subha2707/priceoracle/blob/main/server/models/Asset.js"
click node_predictions "https://github.com/subha2707/priceoracle/blob/main/server/models/Prediction.js"
click node_alerts "https://github.com/subha2707/priceoracle/blob/main/server/models/Alert.js"
click node_collector "https://github.com/subha2707/priceoracle/blob/main/ml/data_collection.py"
click node_sentiment "https://github.com/subha2707/priceoracle/blob/main/ml/sentiment_analysis.py"
click node_preprocess "https://github.com/subha2707/priceoracle/blob/main/ml/preprocessing.py"
click node_training "https://github.com/subha2707/priceoracle/blob/main/ml/train_model.py"
click node_mlapi "https://github.com/subha2707/priceoracle/blob/main/ml/api_server.py"
click node_socketserver "https://github.com/subha2707/priceoracle/blob/main/server/server.js"
click node_socketclient "https://github.com/subha2707/priceoracle/blob/main/client/src/context/SocketContext.jsx"

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_app,node_authui,node_dashboard,node_analytics,node_predviews,node_watchlist,node_assetdetail,node_api toneBlue
class node_express,node_authroutes,node_assetroutes,node_predroutes,node_useroutes,node_alertroutes,node_pricesvc,node_runner,node_alertsjob,node_authmw,node_mlbridge toneAmber
class node_collector,node_sentiment,node_preprocess,node_training,node_mlapi toneMint
class node_db,node_users,node_assets,node_predictions,node_alerts toneRose
class node_socketserver,node_socketclient,node_user,node_market toneIndigo
```

## Components

### Web application

- [Web routes](https://github.com/subha2707/priceoracle/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Account flows](https://github.com/subha2707/priceoracle/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [Prices dashboard](https://github.com/subha2707/priceoracle/blob/main/client/src/pages/Dashboard.jsx): `client/src/pages/Dashboard.jsx`
- [Analytics views](https://github.com/subha2707/priceoracle/blob/main/client/src/pages/Analytics.jsx): `client/src/pages/Analytics.jsx`
- [Predictions views](https://github.com/subha2707/priceoracle/blob/main/client/src/pages/Predictions.jsx): `client/src/pages/Predictions.jsx`
- [Watchlist](https://github.com/subha2707/priceoracle/blob/main/client/src/pages/Watchlist.jsx): `client/src/pages/Watchlist.jsx`
- [Asset detail](https://github.com/subha2707/priceoracle/blob/main/client/src/pages/AssetDetail.jsx): `client/src/pages/AssetDetail.jsx`
- [HTTP client](https://github.com/subha2707/priceoracle/blob/main/client/src/api/axios.js): `client/src/api/axios.js`

### API and services

- [API application](https://github.com/subha2707/priceoracle/blob/main/server/app.js): `server/app.js`
- [Authentication](https://github.com/subha2707/priceoracle/blob/main/server/routes/auth.js): `server/routes/auth.js`
- [Asset endpoints](https://github.com/subha2707/priceoracle/blob/main/server/routes/assets.js): `server/routes/assets.js`
- [Prediction endpoints](https://github.com/subha2707/priceoracle/blob/main/server/routes/predictions.js): `server/routes/predictions.js`
- [User endpoints](https://github.com/subha2707/priceoracle/blob/main/server/routes/user.js): `server/routes/user.js`
- [Alert endpoints](https://github.com/subha2707/priceoracle/blob/main/server/routes/alerts.js): `server/routes/alerts.js`
- [Price service](https://github.com/subha2707/priceoracle/blob/main/server/services/priceService.js): `server/services/priceService.js`
- [Prediction scheduler](https://github.com/subha2707/priceoracle/blob/main/server/jobs/predictionRunner.js): `server/jobs/predictionRunner.js`
- [Alert checker](https://github.com/subha2707/priceoracle/blob/main/server/jobs/alertChecker.js): `server/jobs/alertChecker.js`
- [Token middleware](https://github.com/subha2707/priceoracle/blob/main/server/middleware/auth.js): `server/middleware/auth.js`
- [ML API bridge](https://github.com/subha2707/priceoracle/blob/main/server/services/mlBridge.js): `server/services/mlBridge.js`

### Market data and ML

- [Market collection](https://github.com/subha2707/priceoracle/blob/main/ml/data_collection.py): `ml/data_collection.py`
- [Sentiment analysis](https://github.com/subha2707/priceoracle/blob/main/ml/sentiment_analysis.py): `ml/sentiment_analysis.py`
- [Preprocessing](https://github.com/subha2707/priceoracle/blob/main/ml/preprocessing.py): `ml/preprocessing.py`
- [Model training](https://github.com/subha2707/priceoracle/blob/main/ml/train_model.py): `ml/train_model.py`
- [Prediction API](https://github.com/subha2707/priceoracle/blob/main/ml/api_server.py): `ml/api_server.py`

### Persistent data

- [MongoDB](https://github.com/subha2707/priceoracle/blob/main/server/config/db.js): `server/config/db.js`
- [User records](https://github.com/subha2707/priceoracle/blob/main/server/models/User.js): `server/models/User.js`
- [Asset records](https://github.com/subha2707/priceoracle/blob/main/server/models/Asset.js): `server/models/Asset.js`
- [Prediction records](https://github.com/subha2707/priceoracle/blob/main/server/models/Prediction.js): `server/models/Prediction.js`
- [Alert records](https://github.com/subha2707/priceoracle/blob/main/server/models/Alert.js): `server/models/Alert.js`

### Live updates

- [Socket.IO server](https://github.com/subha2707/priceoracle/blob/main/server/server.js): `server/server.js`
- [Live client](https://github.com/subha2707/priceoracle/blob/main/client/src/context/SocketContext.jsx): `client/src/context/SocketContext.jsx`

### Other components

- **Investor**
- **Market data sources**

## Connections

- Investor → Web routes: browses (evidence: `client/src/App.jsx`)
- Web routes → Account flows: provides auth (evidence: `client/src/App.jsx`)
- Web routes → Prices dashboard: routes to (evidence: `client/src/App.jsx`)
- Web routes → Analytics views: routes to (evidence: `client/src/App.jsx`)
- Web routes → Predictions views: routes to (evidence: `client/src/App.jsx`)
- Web routes → Watchlist: routes to (evidence: `client/src/App.jsx`)
- Web routes → Asset detail: routes to (evidence: `client/src/App.jsx`)
- Account flows → HTTP client: calls (evidence: `client/src/context/AuthContext.jsx`)
- Prices dashboard → HTTP client: requests data (evidence: `client/src/pages/Dashboard.jsx`)
- HTTP client → API application: HTTP requests
- API application → Authentication: mounts (evidence: `server/app.js`)
- API application → Asset endpoints: mounts (evidence: `server/app.js`)
- API application → Prediction endpoints: mounts (evidence: `server/app.js`)
- API application → Alert endpoints: mounts (evidence: `server/app.js`)
- API application → User endpoints: mounts (evidence: `server/app.js`)
- Authentication → User records: reads and writes (evidence: `server/routes/auth.js`)
- Authentication → Alert records: uses OTP records (evidence: `server/routes/auth.js`)
- Authentication → Token middleware: protects logout (evidence: `server/routes/auth.js`)
- Token middleware → User records: loads user (evidence: `server/middleware/auth.js`)
- Prediction endpoints → Token middleware: authenticates (evidence: `server/routes/predictions.js`)
- Prediction endpoints → Prediction records: reads and writes (evidence: `server/routes/predictions.js`)
- Prediction endpoints → Asset records: reads assets (evidence: `server/routes/predictions.js`)
- Prediction endpoints → ML API bridge: requests predictions (evidence: `server/routes/predictions.js`)
- User endpoints → Token middleware: authenticates (evidence: `server/routes/user.js`)
- User endpoints → User records: updates profile (evidence: `server/routes/user.js`)
- User endpoints → Asset records: accesses assets (evidence: `server/routes/user.js`)
- Alert endpoints → Token middleware: authenticates (evidence: `server/routes/alerts.js`)
- Alert endpoints → Alert records: manages alerts (evidence: `server/routes/alerts.js`)
- Price service → ML API bridge: fetches prices (evidence: `server/services/priceService.js`)
- Price service → Asset records: updates assets (evidence: `server/services/priceService.js`)
- Prediction scheduler → ML API bridge: fetches predictions (evidence: `server/jobs/predictionRunner.js`)
- Prediction scheduler → Prediction records: saves predictions (evidence: `server/jobs/predictionRunner.js`)
- Socket.IO server → Price service: starts sync (evidence: `server/server.js`)
- Socket.IO server → Prediction scheduler: starts job (evidence: `server/server.js`)
- Socket.IO server → Alert checker: starts checker (evidence: `server/server.js`)
- Live client → Socket.IO server: joins live rooms
- Market data sources → Market collection: supplies data
- Market collection → Sentiment analysis: pipeline stage
- Sentiment analysis → Preprocessing: pipeline stage
- Preprocessing → Model training: pipeline stage
- Model training → Prediction API: serves models
- Prediction API → ML API bridge: provides ML API
- Socket.IO server → Live client: pushes updates
- Socket.IO server → MongoDB: connects (evidence: `server/server.js`)
