# sahlaca/costestimation_fullstack architecture

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

- Interactive diagram: https://gitdiagram.com/sahlaca/costestimation_fullstack
- Repository: https://github.com/sahlaca/costestimation_fullstack

## Overview

This is a CAD cost-estimation suite: a user signs in, uploads a STEP part, receives geometry-derived material and machining-cost estimates, and can review prior estimates and application logs. The frontend dashboard calls FastAPI endpoints; prediction handling authenticates the user, invokes the estimation service, and persists results and logs. Authentication, CAD estimation, and monitoring are distinct product stages. The README documents the NGINX and PostgreSQL deployment. Some frontend and backend files were not sampled, so undocumented runtime links are omitted.

Main entry points: [`backend/routers/auth.py`](https://github.com/sahlaca/costestimation_fullstack/blob/main/backend/routers/auth.py) (Auth routes), [`backend/main.py`](https://github.com/sahlaca/costestimation_fullstack/blob/main/backend/main.py) (FastAPI app), [`backend/routers/predict.py`](https://github.com/sahlaca/costestimation_fullstack/blob/main/backend/routers/predict.py) (Prediction routes), [`backend/models/models.py`](https://github.com/sahlaca/costestimation_fullstack/blob/main/backend/models/models.py) (Data models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Web interface"]
  node_dashboard["Estimator dashboard<br/>[page.tsx]"]
  node_login["Login page<br/>[page.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_api["API and identity"]
  node_app["FastAPI app<br/>[main.py]"]
  node_auth_routes["Auth routes<br/>[auth.py]"]
  node_auth_service["Password and tokens<br/>[auth_service.py]"]
  node_schemas["Request and response schemas<br/>[schemas.py]"]
end

subgraph group_estimation["Cost estimation"]
  node_predict_routes["Prediction routes<br/>[predict.py]"]
  node_estimator["STEP analysis and costing"]
end

subgraph group_persistence["Persistence and monitoring"]
  node_history["Prediction history<br/>[predict.py]"]
  node_log_routes["Application logs<br/>[logs.py]"]
  node_models["Data models<br/>[models.py]"]
  node_database["Database session and engine<br/>[database.py]"]
end

node_user(("User"))
node_nginx["NGINX proxy<br/>[nginx.conf]"]
node_postgres[("PostgreSQL")]

node_user -->|"opens suite"| node_nginx
node_nginx -->|"routes web traffic"| node_dashboard
node_nginx -->|"routes API traffic"| node_app
node_dashboard -->|"uses"| node_api_client
node_dashboard -->|"requests estimates, history, logs"| node_app
node_app -->|"registers"| node_auth_routes
node_app -->|"registers"| node_predict_routes
node_app -->|"registers"| node_log_routes
node_app -->|"creates tables and session"| node_database
node_auth_routes -->|"hashes and signs"| node_auth_service
node_auth_routes -->|"queries and persists users"| node_models
node_auth_routes -->|"validates responses"| node_schemas
node_predict_routes -->|"requires current user"| node_auth_routes
node_predict_routes -->|"estimates costs"| node_estimator
node_predict_routes -->|"writes prediction and app logs"| node_models
node_predict_routes -->|"shapes response"| node_schemas
node_history -->|"requires current user"| node_auth_routes
node_history -->|"queries estimates"| node_models
node_log_routes -->|"requires current user"| node_auth_routes
node_log_routes -->|"writes and queries logs"| node_models
node_models -->|"uses declarative base"| node_database
node_database -.->|"connects to configured database"| node_postgres

click node_nginx "https://github.com/sahlaca/costestimation_fullstack/blob/main/nginx.conf"
click node_dashboard "https://github.com/sahlaca/costestimation_fullstack/blob/main/frontend/src/app/page.tsx"
click node_login "https://github.com/sahlaca/costestimation_fullstack/blob/main/frontend/src/app/login/page.tsx"
click node_api_client "https://github.com/sahlaca/costestimation_fullstack/blob/main/frontend/src/lib/api.ts"
click node_app "https://github.com/sahlaca/costestimation_fullstack/blob/main/backend/main.py"
click node_auth_routes "https://github.com/sahlaca/costestimation_fullstack/blob/main/backend/routers/auth.py"
click node_auth_service "https://github.com/sahlaca/costestimation_fullstack/blob/main/backend/services/auth_service.py"
click node_schemas "https://github.com/sahlaca/costestimation_fullstack/blob/main/backend/schemas/schemas.py"
click node_predict_routes "https://github.com/sahlaca/costestimation_fullstack/blob/main/backend/routers/predict.py"
click node_estimator "https://github.com/sahlaca/costestimation_fullstack/blob/main/backend/services/prediction_service.py"
click node_history "https://github.com/sahlaca/costestimation_fullstack/blob/main/backend/routers/predict.py"
click node_log_routes "https://github.com/sahlaca/costestimation_fullstack/blob/main/backend/routers/logs.py"
click node_models "https://github.com/sahlaca/costestimation_fullstack/blob/main/backend/models/models.py"
click node_database "https://github.com/sahlaca/costestimation_fullstack/blob/main/backend/database.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_dashboard,node_login,node_api_client,node_user toneBlue
class node_app,node_auth_routes,node_auth_service,node_schemas,node_postgres toneAmber
class node_predict_routes,node_estimator toneMint
class node_history,node_log_routes,node_models,node_database toneRose
class node_nginx toneTeal
```

## Components

### Web interface

- [Estimator dashboard](https://github.com/sahlaca/costestimation_fullstack/blob/main/frontend/src/app/page.tsx): `frontend/src/app/page.tsx`
- [Login page](https://github.com/sahlaca/costestimation_fullstack/blob/main/frontend/src/app/login/page.tsx): `frontend/src/app/login/page.tsx`
- [API client](https://github.com/sahlaca/costestimation_fullstack/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`

### API and identity

- [FastAPI app](https://github.com/sahlaca/costestimation_fullstack/blob/main/backend/main.py): `backend/main.py`
- [Auth routes](https://github.com/sahlaca/costestimation_fullstack/blob/main/backend/routers/auth.py): `backend/routers/auth.py`
- [Password and tokens](https://github.com/sahlaca/costestimation_fullstack/blob/main/backend/services/auth_service.py): `backend/services/auth_service.py`
- [Request and response schemas](https://github.com/sahlaca/costestimation_fullstack/blob/main/backend/schemas/schemas.py): `backend/schemas/schemas.py`

### Cost estimation

- [Prediction routes](https://github.com/sahlaca/costestimation_fullstack/blob/main/backend/routers/predict.py): `backend/routers/predict.py`
- [STEP analysis and costing](https://github.com/sahlaca/costestimation_fullstack/blob/main/backend/services/prediction_service.py): `backend/services/prediction_service.py`

### Persistence and monitoring

- [Prediction history](https://github.com/sahlaca/costestimation_fullstack/blob/main/backend/routers/predict.py): `backend/routers/predict.py`
- [Application logs](https://github.com/sahlaca/costestimation_fullstack/blob/main/backend/routers/logs.py): `backend/routers/logs.py`
- [Data models](https://github.com/sahlaca/costestimation_fullstack/blob/main/backend/models/models.py): `backend/models/models.py`
- [Database session and engine](https://github.com/sahlaca/costestimation_fullstack/blob/main/backend/database.py): `backend/database.py`

### Other components

- **User**
- [NGINX proxy](https://github.com/sahlaca/costestimation_fullstack/blob/main/nginx.conf): `nginx.conf`
- **PostgreSQL**

## Connections

- User → NGINX proxy: opens suite (evidence: `README.md`)
- NGINX proxy → Estimator dashboard: routes web traffic (evidence: `README.md`)
- NGINX proxy → FastAPI app: routes API traffic (evidence: `README.md`)
- Estimator dashboard → API client: uses (evidence: `frontend/src/app/page.tsx`)
- Estimator dashboard → FastAPI app: requests estimates, history, logs (evidence: `frontend/src/app/page.tsx`)
- FastAPI app → Auth routes: registers (evidence: `backend/main.py`)
- FastAPI app → Prediction routes: registers (evidence: `backend/main.py`)
- FastAPI app → Application logs: registers (evidence: `backend/main.py`)
- FastAPI app → Database session and engine: creates tables and session (evidence: `backend/main.py`)
- Auth routes → Password and tokens: hashes and signs (evidence: `backend/routers/auth.py`)
- Auth routes → Data models: queries and persists users (evidence: `backend/routers/auth.py`)
- Auth routes → Request and response schemas: validates responses (evidence: `backend/routers/auth.py`)
- Prediction routes → Auth routes: requires current user (evidence: `backend/routers/predict.py`)
- Prediction routes → STEP analysis and costing: estimates costs (evidence: `backend/routers/predict.py`)
- Prediction routes → Data models: writes prediction and app logs (evidence: `backend/routers/predict.py`)
- Prediction routes → Request and response schemas: shapes response (evidence: `backend/routers/predict.py`)
- Prediction history → Auth routes: requires current user (evidence: `backend/routers/predict.py`)
- Prediction history → Data models: queries estimates (evidence: `backend/routers/predict.py`)
- Application logs → Auth routes: requires current user (evidence: `backend/routers/logs.py`)
- Application logs → Data models: writes and queries logs (evidence: `backend/routers/logs.py`)
- Data models → Database session and engine: uses declarative base (evidence: `backend/models/models.py`)
- Database session and engine → PostgreSQL: connects to configured database (evidence: `README.md`)
