# phuwanat48/massiveapi architecture

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

- Interactive diagram: https://gitdiagram.com/phuwanat48/massiveapi
- Repository: https://github.com/phuwanat48/massiveapi

## Overview

This NestJS API accepts a validated movers-calculation request, checks stored price history, fetches prices from Polygon/Massive when history is incomplete, computes and ranks movers, persists the latest results, and returns them. The graph follows the sampled controller, service, repository, and API-client calls. Storage entity paths and app registration are visible in the excerpts; Swagger and migration details are documented or present in the tree but their runtime wiring is not fully sampled.

Main entry points: [`src/modules/movers/movers.service.ts`](https://github.com/phuwanat48/massiveapi/blob/main/src/modules/movers/movers.service.ts) (Calculation and ranking), [`src/modules/movers/repositories/movers.repository.ts`](https://github.com/phuwanat48/massiveapi/blob/main/src/modules/movers/repositories/movers.repository.ts) (Price and result access), [`src/modules/movers/movers.controller.ts`](https://github.com/phuwanat48/massiveapi/blob/main/src/modules/movers/movers.controller.ts) (Calculate endpoint), [`src/app.module.ts`](https://github.com/phuwanat48/massiveapi/blob/main/src/app.module.ts) (Application registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API entry"]
  node_movers_controller["Calculate endpoint"]
  node_request_dto["Request validation"]
  node_app_module["Application registration<br/>[app.module.ts]"]
  node_swagger["Swagger UI<br/>[main.ts]"]
  node_app_controller["Root endpoint<br/>[app.controller.ts]"]
  node_app_service["Root greeting<br/>[app.service.ts]"]
end

subgraph group_calculation["Mover calculation"]
  node_movers_service["Calculation and ranking<br/>[movers.service.ts]"]
end

subgraph group_data["Market data"]
  node_movers_repository["Price and result access"]
  node_massive_client["Polygon price client"]
  node_stock_prices[("Stock price history")]
  node_mover_results[("Saved mover results")]
end

node_client(("API client"))
node_polygon{{"Polygon API"}}

node_client -->|"POST calculate"| node_movers_controller
node_movers_controller -->|"validates body"| node_request_dto
node_movers_controller -->|"calls calculate"| node_movers_service
node_movers_service -->|"checks history"| node_movers_repository
node_movers_service -->|"fetches if incomplete"| node_massive_client
node_massive_client -->|"requests prices"| node_polygon
node_movers_service -->|"upserts fetched prices"| node_movers_repository
node_movers_repository -->|"reads and writes"| node_stock_prices
node_movers_service -->|"loads comparisons"| node_movers_repository
node_movers_service -->|"saves ranked results"| node_movers_repository
node_movers_repository -->|"replaces latest results"| node_mover_results
node_app_module -->|"registers module"| node_movers_controller
node_app_module -->|"registers controller"| node_app_controller
node_app_controller -->|"calls greeting"| node_app_service
node_client -->|"opens API docs"| node_swagger

click node_movers_controller "https://github.com/phuwanat48/massiveapi/blob/main/src/modules/movers/movers.controller.ts"
click node_request_dto "https://github.com/phuwanat48/massiveapi/blob/main/src/modules/movers/dto/calculate-movers.dto.ts"
click node_movers_service "https://github.com/phuwanat48/massiveapi/blob/main/src/modules/movers/movers.service.ts"
click node_movers_repository "https://github.com/phuwanat48/massiveapi/blob/main/src/modules/movers/repositories/movers.repository.ts"
click node_massive_client "https://github.com/phuwanat48/massiveapi/blob/main/src/modules/movers/services/movers-massive-api.service.ts"
click node_stock_prices "https://github.com/phuwanat48/massiveapi/blob/main/src/modules/movers/entities/stock-price.entity.ts"
click node_mover_results "https://github.com/phuwanat48/massiveapi/blob/main/src/modules/movers/entities/mover-result.entity.ts"
click node_app_module "https://github.com/phuwanat48/massiveapi/blob/main/src/app.module.ts"
click node_swagger "https://github.com/phuwanat48/massiveapi/blob/main/src/main.ts"
click node_app_controller "https://github.com/phuwanat48/massiveapi/blob/main/src/app.controller.ts"
click node_app_service "https://github.com/phuwanat48/massiveapi/blob/main/src/app.service.ts"

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_movers_controller,node_request_dto,node_app_module,node_swagger,node_app_controller,node_app_service,node_client toneBlue
class node_movers_service toneAmber
class node_movers_repository,node_massive_client,node_stock_prices,node_mover_results,node_polygon toneMint
```

## Components

### API entry

- [Calculate endpoint](https://github.com/phuwanat48/massiveapi/blob/main/src/modules/movers/movers.controller.ts): `src/modules/movers/movers.controller.ts`
- [Request validation](https://github.com/phuwanat48/massiveapi/blob/main/src/modules/movers/dto/calculate-movers.dto.ts): `src/modules/movers/dto/calculate-movers.dto.ts`
- [Application registration](https://github.com/phuwanat48/massiveapi/blob/main/src/app.module.ts): `src/app.module.ts`
- [Swagger UI](https://github.com/phuwanat48/massiveapi/blob/main/src/main.ts): `src/main.ts`
- [Root endpoint](https://github.com/phuwanat48/massiveapi/blob/main/src/app.controller.ts): `src/app.controller.ts`
- [Root greeting](https://github.com/phuwanat48/massiveapi/blob/main/src/app.service.ts): `src/app.service.ts`

### Mover calculation

- [Calculation and ranking](https://github.com/phuwanat48/massiveapi/blob/main/src/modules/movers/movers.service.ts): `src/modules/movers/movers.service.ts`

### Market data

- [Price and result access](https://github.com/phuwanat48/massiveapi/blob/main/src/modules/movers/repositories/movers.repository.ts): `src/modules/movers/repositories/movers.repository.ts`
- [Polygon price client](https://github.com/phuwanat48/massiveapi/blob/main/src/modules/movers/services/movers-massive-api.service.ts): `src/modules/movers/services/movers-massive-api.service.ts`
- [Stock price history](https://github.com/phuwanat48/massiveapi/blob/main/src/modules/movers/entities/stock-price.entity.ts): `src/modules/movers/entities/stock-price.entity.ts`
- [Saved mover results](https://github.com/phuwanat48/massiveapi/blob/main/src/modules/movers/entities/mover-result.entity.ts): `src/modules/movers/entities/mover-result.entity.ts`

### Other components

- **API client**
- **Polygon API**

## Connections

- API client → Calculate endpoint: POST calculate (evidence: `README.md`)
- Calculate endpoint → Request validation: validates body (evidence: `src/modules/movers/movers.controller.ts`)
- Calculate endpoint → Calculation and ranking: calls calculate (evidence: `src/modules/movers/movers.controller.ts`)
- Calculation and ranking → Price and result access: checks history (evidence: `src/modules/movers/movers.service.ts`)
- Calculation and ranking → Polygon price client: fetches if incomplete (evidence: `src/modules/movers/movers.service.ts`)
- Polygon price client → Polygon API: requests prices (evidence: `src/modules/movers/services/movers-massive-api.service.ts`)
- Calculation and ranking → Price and result access: upserts fetched prices (evidence: `src/modules/movers/movers.service.ts`)
- Price and result access → Stock price history: reads and writes (evidence: `src/modules/movers/repositories/movers.repository.ts`)
- Calculation and ranking → Price and result access: loads comparisons (evidence: `src/modules/movers/movers.service.ts`)
- Calculation and ranking → Price and result access: saves ranked results (evidence: `src/modules/movers/movers.service.ts`)
- Price and result access → Saved mover results: replaces latest results (evidence: `src/modules/movers/repositories/movers.repository.ts`)
- Application registration → Calculate endpoint: registers module (evidence: `src/app.module.ts`)
- Application registration → Root endpoint: registers controller (evidence: `src/app.module.ts`)
- Root endpoint → Root greeting: calls greeting (evidence: `src/app.controller.ts`)
- API client → Swagger UI: opens API docs (evidence: `README.md`)
