# u240476/trading-fullstack architecture

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

- Interactive diagram: https://gitdiagram.com/u240476/trading-fullstack
- Repository: https://github.com/u240476/trading-fullstack

## Overview

This is a full-stack portfolio selection and analysis application, extended with a Spring Boot microservice. The intended user flow is to explore prices and portfolio/optimization visualizations in the frontend; the Express API exposes analysis endpoints and forwards requests to the Java service. Account registration, login, and deletion form a separate authenticated workflow. The Java tree indicates distinct market-data, portfolio, optimization, and calculation subsystems, but their internal call relationships were not sampled. Frontend-to-API wiring is likewise not evidenced in the excerpts, so those links are marked unverified.

Main entry points: [`backend/server.js`](https://github.com/u240476/trading-fullstack/blob/main/backend/server.js) (API server), [`java-service/src/main/java/com/example/controller`](https://github.com/u240476/trading-fullstack/tree/main/java-service/src/main/java/com/example/controller) (Analysis endpoints), [`backend/authRoutes/authRoute.js`](https://github.com/u240476/trading-fullstack/blob/main/backend/authRoutes/authRoute.js) (Auth routes), [`java-service/src/main/java/com/example/service`](https://github.com/u240476/trading-fullstack/tree/main/java-service/src/main/java/com/example/service) (Portfolio services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User interface"]
  node_portfolio_ui["Portfolio views<br/>[Portfolio.js]"]
  node_prices_ui["Price views<br/>[Prices.js]"]
  node_optimization_ui["Optimization views<br/>[Optimisation.js]"]
  node_graphs_ui["Graph views<br/>[MasterGraph.js]"]
end

subgraph group_gateway["Express API"]
  node_api_server["API server<br/>[server.js]"]
  node_api_routes["Analysis routes"]
  node_master_route["Master graph"]
end

subgraph group_identity["Accounts"]
  node_auth_routes["Auth routes<br/>[authRoute.js]"]
  node_auth_controller["Account operations<br/>[authController.js]"]
  node_auth_middleware["Token validation<br/>[authMiddleware.js]"]
  node_account_model["Account records<br/>[accountModel.js]"]
  node_account_db[("SQLite accounts<br/>[db.js]")]
end

subgraph group_analysis["Portfolio service"]
  node_java_api["Analysis endpoints"]
  node_portfolio_service["Portfolio services"]
  node_optimization["Portfolio optimization"]
  node_calculators["Risk and return math"]
  node_market_data["Stock data client"]
  node_stock_cache["Stock cache"]
end

node_investor(("Investor"))

node_investor -->|"explores"| node_portfolio_ui
node_portfolio_ui -.->|"requests analysis"| node_api_server
node_prices_ui -.->|"requests prices"| node_api_server
node_optimization_ui -.->|"requests optimization"| node_api_server
node_graphs_ui -.->|"requests graphs"| node_api_server
node_api_server -->|"mounts"| node_api_routes
node_api_server -->|"mounts"| node_auth_routes
node_api_routes -->|"forwards requests"| node_java_api
node_master_route -->|"fetches graph data"| node_java_api
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_routes -->|"validates deletion"| node_auth_middleware
node_auth_controller -->|"reads and changes"| node_account_model
node_account_model -->|"queries"| node_account_db
node_java_api -.->|"delegates"| node_portfolio_service
node_portfolio_service -.->|"uses"| node_optimization
node_portfolio_service -.->|"uses"| node_calculators
node_java_api -.->|"fetches prices"| node_market_data
node_market_data -.->|"uses cache"| node_stock_cache

click node_portfolio_ui "https://github.com/u240476/trading-fullstack/blob/main/frontend/Portfolio.js"
click node_prices_ui "https://github.com/u240476/trading-fullstack/blob/main/frontend/Prices.js"
click node_optimization_ui "https://github.com/u240476/trading-fullstack/blob/main/frontend/Optimisation.js"
click node_graphs_ui "https://github.com/u240476/trading-fullstack/blob/main/frontend/MasterGraph.js"
click node_api_server "https://github.com/u240476/trading-fullstack/blob/main/backend/server.js"
click node_api_routes "https://github.com/u240476/trading-fullstack/tree/main/backend/routes"
click node_master_route "https://github.com/u240476/trading-fullstack/blob/main/backend/routes/MasterGraphRoute.js"
click node_auth_routes "https://github.com/u240476/trading-fullstack/blob/main/backend/authRoutes/authRoute.js"
click node_auth_controller "https://github.com/u240476/trading-fullstack/blob/main/backend/authControllers/authController.js"
click node_auth_middleware "https://github.com/u240476/trading-fullstack/blob/main/backend/middleware/authMiddleware.js"
click node_account_model "https://github.com/u240476/trading-fullstack/blob/main/backend/models/accountModel.js"
click node_account_db "https://github.com/u240476/trading-fullstack/blob/main/backend/config/db.js"
click node_java_api "https://github.com/u240476/trading-fullstack/tree/main/java-service/src/main/java/com/example/controller"
click node_portfolio_service "https://github.com/u240476/trading-fullstack/tree/main/java-service/src/main/java/com/example/service"
click node_optimization "https://github.com/u240476/trading-fullstack/tree/main/java-service/src/main/java/com/example/optimisation"
click node_calculators "https://github.com/u240476/trading-fullstack/tree/main/java-service/src/main/java/com/example/math"
click node_market_data "https://github.com/u240476/trading-fullstack/tree/main/java-service/src/main/java/com/example/client"
click node_stock_cache "https://github.com/u240476/trading-fullstack/tree/main/java-service/src/main/java/com/example/cache"

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_portfolio_ui,node_prices_ui,node_optimization_ui,node_graphs_ui toneBlue
class node_api_server,node_api_routes,node_master_route toneAmber
class node_auth_routes,node_auth_controller,node_auth_middleware,node_account_model,node_account_db toneMint
class node_java_api,node_portfolio_service,node_optimization,node_calculators,node_market_data,node_stock_cache toneRose
class node_investor toneIndigo
```

## Components

### User interface

- [Portfolio views](https://github.com/u240476/trading-fullstack/blob/main/frontend/Portfolio.js): `frontend/Portfolio.js`
- [Price views](https://github.com/u240476/trading-fullstack/blob/main/frontend/Prices.js): `frontend/Prices.js`
- [Optimization views](https://github.com/u240476/trading-fullstack/blob/main/frontend/Optimisation.js): `frontend/Optimisation.js`
- [Graph views](https://github.com/u240476/trading-fullstack/blob/main/frontend/MasterGraph.js): `frontend/MasterGraph.js`

### Express API

- [API server](https://github.com/u240476/trading-fullstack/blob/main/backend/server.js): `backend/server.js`
- [Analysis routes](https://github.com/u240476/trading-fullstack/tree/main/backend/routes): `backend/routes`
- [Master graph](https://github.com/u240476/trading-fullstack/blob/main/backend/routes/MasterGraphRoute.js): `backend/routes/MasterGraphRoute.js`

### Accounts

- [Auth routes](https://github.com/u240476/trading-fullstack/blob/main/backend/authRoutes/authRoute.js): `backend/authRoutes/authRoute.js`
- [Account operations](https://github.com/u240476/trading-fullstack/blob/main/backend/authControllers/authController.js): `backend/authControllers/authController.js`
- [Token validation](https://github.com/u240476/trading-fullstack/blob/main/backend/middleware/authMiddleware.js): `backend/middleware/authMiddleware.js`
- [Account records](https://github.com/u240476/trading-fullstack/blob/main/backend/models/accountModel.js): `backend/models/accountModel.js`
- [SQLite accounts](https://github.com/u240476/trading-fullstack/blob/main/backend/config/db.js): `backend/config/db.js`

### Portfolio service

- [Analysis endpoints](https://github.com/u240476/trading-fullstack/tree/main/java-service/src/main/java/com/example/controller): `java-service/src/main/java/com/example/controller`
- [Portfolio services](https://github.com/u240476/trading-fullstack/tree/main/java-service/src/main/java/com/example/service): `java-service/src/main/java/com/example/service`
- [Portfolio optimization](https://github.com/u240476/trading-fullstack/tree/main/java-service/src/main/java/com/example/optimisation): `java-service/src/main/java/com/example/optimisation`
- [Risk and return math](https://github.com/u240476/trading-fullstack/tree/main/java-service/src/main/java/com/example/math): `java-service/src/main/java/com/example/math`
- [Stock data client](https://github.com/u240476/trading-fullstack/tree/main/java-service/src/main/java/com/example/client): `java-service/src/main/java/com/example/client`
- [Stock cache](https://github.com/u240476/trading-fullstack/tree/main/java-service/src/main/java/com/example/cache): `java-service/src/main/java/com/example/cache`

### Other components

- **Investor**

## Connections

- Investor → Portfolio views: explores (evidence: `README.md`)
- Portfolio views → API server: requests analysis
- Price views → API server: requests prices
- Optimization views → API server: requests optimization
- Graph views → API server: requests graphs
- API server → Analysis routes: mounts (evidence: `backend/server.js`)
- API server → Auth routes: mounts (evidence: `backend/server.js`)
- Analysis routes → Analysis endpoints: forwards requests (evidence: `backend/routes/PortfolioStandardDeviationRoute.js`)
- Master graph → Analysis endpoints: fetches graph data (evidence: `backend/routes/MasterGraphRoute.js`)
- Auth routes → Account operations: dispatches (evidence: `backend/authRoutes/authRoute.js`)
- Auth routes → Token validation: validates deletion (evidence: `backend/authRoutes/authRoute.js`)
- Account operations → Account records: reads and changes (evidence: `backend/authControllers/authController.js`)
- Account records → SQLite accounts: queries (evidence: `backend/models/accountModel.js`)
- Analysis endpoints → Portfolio services: delegates
- Portfolio services → Portfolio optimization: uses
- Portfolio services → Risk and return math: uses
- Analysis endpoints → Stock data client: fetches prices
- Stock data client → Stock cache: uses cache
