# jorgesancere/prediction-service architecture

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

- Interactive diagram: https://gitdiagram.com/jorgesancere/prediction-service
- Repository: https://github.com/jorgesancere/prediction-service

## Overview

This repository implements an HTTP prediction service. A client calls the prediction endpoint; the route dispatches to a controller, which delegates validation, normalization and ONNX inference to the prediction service. The service records each successful result through a Mongoose model in MongoDB and returns prediction metadata. Startup connects to MongoDB, initializes the ONNX model, then starts the HTTP listener. The source excerpts show these main calls and the model artifacts; there is no README, so additional product capabilities are not documented.

Main entry points: [`src/services/prediction.service.js`](https://github.com/jorgesancere/prediction-service/blob/main/src/services/prediction.service.js) (Prediction service), [`server.js`](https://github.com/jorgesancere/prediction-service/blob/main/server.js) (Server startup), [`src/routes/prediction.routes.js`](https://github.com/jorgesancere/prediction-service/blob/main/src/routes/prediction.routes.js) (Prediction routes), [`src/app.js`](https://github.com/jorgesancere/prediction-service/blob/main/src/app.js) (Express app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_app["Express app<br/>[app.js]"]
  node_routes["Prediction routes"]
  node_controller["Prediction controller"]
end

subgraph group_inference["Inference"]
  node_service["Prediction service"]
  node_onnx["ONNX model<br/>[modelo.onnx]"]
  node_normalization["Normalization settings<br/>[normalizacion.json]"]
end

subgraph group_runtime["Runtime and storage"]
  node_server["Server startup<br/>[server.js]"]
  node_prediction_model["Prediction record model"]
end

node_client(("API client"))
node_mongodb[("MongoDB")]

node_client -->|"calls HTTP"| node_routes
node_routes -->|"dispatches to"| node_controller
node_controller -->|"requests prediction"| node_service
node_app -->|"registers"| node_routes
node_server -->|"starts listener"| node_app
node_server -->|"initializes model"| node_service
node_server -->|"connects to"| node_mongodb
node_service -->|"loads and runs"| node_onnx
node_service -->|"reads settings"| node_normalization
node_service -->|"creates and saves"| node_prediction_model
node_prediction_model -->|"persists records"| node_mongodb

click node_server "https://github.com/jorgesancere/prediction-service/blob/main/server.js"
click node_app "https://github.com/jorgesancere/prediction-service/blob/main/src/app.js"
click node_routes "https://github.com/jorgesancere/prediction-service/blob/main/src/routes/prediction.routes.js"
click node_controller "https://github.com/jorgesancere/prediction-service/blob/main/src/controllers/prediction.controller.js"
click node_service "https://github.com/jorgesancere/prediction-service/blob/main/src/services/prediction.service.js"
click node_onnx "https://github.com/jorgesancere/prediction-service/blob/main/modelo/modelo.onnx"
click node_normalization "https://github.com/jorgesancere/prediction-service/blob/main/modelo/normalizacion.json"
click node_prediction_model "https://github.com/jorgesancere/prediction-service/blob/main/src/models/prediction.model.js"

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_routes,node_controller,node_client toneBlue
class node_service,node_onnx,node_normalization,node_mongodb toneAmber
class node_server,node_prediction_model toneMint
```

## Components

### HTTP API

- [Express app](https://github.com/jorgesancere/prediction-service/blob/main/src/app.js): `src/app.js`
- [Prediction routes](https://github.com/jorgesancere/prediction-service/blob/main/src/routes/prediction.routes.js): `src/routes/prediction.routes.js`
- [Prediction controller](https://github.com/jorgesancere/prediction-service/blob/main/src/controllers/prediction.controller.js): `src/controllers/prediction.controller.js`

### Inference

- [Prediction service](https://github.com/jorgesancere/prediction-service/blob/main/src/services/prediction.service.js): `src/services/prediction.service.js`
- [ONNX model](https://github.com/jorgesancere/prediction-service/blob/main/modelo/modelo.onnx): `modelo/modelo.onnx`
- [Normalization settings](https://github.com/jorgesancere/prediction-service/blob/main/modelo/normalizacion.json): `modelo/normalizacion.json`

### Runtime and storage

- [Server startup](https://github.com/jorgesancere/prediction-service/blob/main/server.js): `server.js`
- [Prediction record model](https://github.com/jorgesancere/prediction-service/blob/main/src/models/prediction.model.js): `src/models/prediction.model.js`

### Other components

- **API client**
- **MongoDB**

## Connections

- API client → Prediction routes: calls HTTP (evidence: `src/routes/prediction.routes.js`)
- Prediction routes → Prediction controller: dispatches to (evidence: `src/routes/prediction.routes.js`)
- Prediction controller → Prediction service: requests prediction (evidence: `src/controllers/prediction.controller.js`)
- Express app → Prediction routes: registers (evidence: `src/app.js`)
- Server startup → Express app: starts listener (evidence: `server.js`)
- Server startup → Prediction service: initializes model (evidence: `server.js`)
- Server startup → MongoDB: connects to (evidence: `server.js`)
- Prediction service → ONNX model: loads and runs (evidence: `src/services/prediction.service.js`)
- Prediction service → Normalization settings: reads settings (evidence: `src/services/prediction.service.js`)
- Prediction service → Prediction record model: creates and saves (evidence: `src/services/prediction.service.js`)
- Prediction record model → MongoDB: persists records (evidence: `src/models/prediction.model.js`)
