# adamakhiat/thermstream architecture

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

- Interactive diagram: https://gitdiagram.com/adamakhiat/thermstream
- Repository: https://github.com/adamakhiat/thermstream

## Overview

This NestJS backend accepts sensor readings over HTTP, validates and publishes them to Kafka, then consumes batches and persists them through Prisma to PostgreSQL. It also exposes a simple greeting endpoint and a separate Socket.IO gateway that emits a periodic message. The graph reflects the shown wiring and calls; there is no README content, and the database schema and unsampled runtime details are not described further.

Main entry points: [`backend/backend/src/app.module.ts`](https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/app.module.ts) (Application Wiring), [`backend/backend/src/temp/temp.controller.ts`](https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/temp/temp.controller.ts) (Reading Endpoint), [`backend/backend/src/temp/temp.module.ts`](https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/temp/temp.module.ts) (Reading Module), [`backend/backend/src/temp/temp.service.ts`](https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/temp/temp.service.ts) (Batch Consumer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP API"]
  node_app_module["Application Wiring<br/>[app.module.ts]"]
  node_app_controller["Greeting Route<br/>[app.controller.ts]"]
  node_app_service["Greeting Service<br/>[app.service.ts]"]
  node_temp_controller["Reading Endpoint<br/>[temp.controller.ts]"]
  node_temp_dto["Reading Validation<br/>[temp.dto.ts]"]
  node_temp_module["Reading Module<br/>[temp.module.ts]"]
end

subgraph group_messaging["Kafka Ingestion"]
  node_kafka_module["Kafka Client Setup<br/>[kafka.module.ts]"]
  node_temp_service["Batch Consumer<br/>[temp.service.ts]"]
end

subgraph group_storage["Persistence"]
  node_prisma_module["Prisma Module<br/>[prisma.module.ts]"]
  node_prisma_service["Prisma Client<br/>[prisma.service.ts]"]
end

subgraph group_realtime["Realtime Events"]
  node_events_module["Events Module<br/>[events.module.ts]"]
  node_events_gateway["Socket.IO Gateway<br/>[events.gateway.ts]"]
end

node_http_client(("HTTP Client"))
node_bootstrap["Nest Bootstrap<br/>[main.ts]"]
node_kafka["Kafka"]
node_postgres[("PostgreSQL")]
node_socket_client(("Socket.IO Client"))

node_bootstrap -->|"boots"| node_app_module
node_app_module -->|"imports"| node_temp_module
node_app_module -->|"imports"| node_prisma_module
node_app_module -->|"imports"| node_kafka_module
node_app_module -->|"imports"| node_events_module
node_http_client -.->|"requests"| node_app_controller
node_app_controller -->|"calls"| node_app_service
node_http_client -.->|"posts readings"| node_temp_controller
node_temp_controller -->|"validates with"| node_temp_dto
node_temp_controller -->|"publishes readings"| node_kafka
node_temp_controller -.->|"injects client"| node_kafka_module
node_temp_module -->|"registers"| node_temp_controller
node_temp_module -->|"provides"| node_temp_service
node_temp_module -->|"imports"| node_kafka_module
node_temp_service -->|"consumes batches"| node_kafka
node_temp_service -->|"writes readings"| node_prisma_service
node_prisma_module -->|"provides"| node_prisma_service
node_prisma_service -->|"connects to"| node_postgres
node_events_module -->|"provides"| node_events_gateway
node_socket_client -->|"connects"| node_events_gateway
node_events_gateway -->|"emits messages"| node_socket_client

click node_bootstrap "https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/main.ts"
click node_app_module "https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/app.module.ts"
click node_app_controller "https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/app.controller.ts"
click node_app_service "https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/app.service.ts"
click node_temp_controller "https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/temp/temp.controller.ts"
click node_temp_dto "https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/dto/temp.dto.ts"
click node_temp_module "https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/temp/temp.module.ts"
click node_kafka_module "https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/kafka/kafka.module.ts"
click node_temp_service "https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/temp/temp.service.ts"
click node_prisma_module "https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/prisma.module.ts"
click node_prisma_service "https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/prisma.service.ts"
click node_events_module "https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/events/events.module.ts"
click node_events_gateway "https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/events/events.gateway.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_app_module,node_app_controller,node_app_service,node_temp_controller,node_temp_dto,node_temp_module,node_http_client,node_socket_client toneBlue
class node_kafka_module,node_temp_service,node_postgres toneAmber
class node_prisma_module,node_prisma_service toneMint
class node_events_module,node_events_gateway toneRose
class node_bootstrap toneTeal
class node_kafka toneIndigo
```

## Components

### HTTP API

- [Application Wiring](https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/app.module.ts): `backend/backend/src/app.module.ts`
- [Greeting Route](https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/app.controller.ts): `backend/backend/src/app.controller.ts`
- [Greeting Service](https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/app.service.ts): `backend/backend/src/app.service.ts`
- [Reading Endpoint](https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/temp/temp.controller.ts): `backend/backend/src/temp/temp.controller.ts`
- [Reading Validation](https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/dto/temp.dto.ts): `backend/backend/src/dto/temp.dto.ts`
- [Reading Module](https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/temp/temp.module.ts): `backend/backend/src/temp/temp.module.ts`

### Kafka Ingestion

- [Kafka Client Setup](https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/kafka/kafka.module.ts): `backend/backend/src/kafka/kafka.module.ts`
- [Batch Consumer](https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/temp/temp.service.ts): `backend/backend/src/temp/temp.service.ts`

### Persistence

- [Prisma Module](https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/prisma.module.ts): `backend/backend/src/prisma.module.ts`
- [Prisma Client](https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/prisma.service.ts): `backend/backend/src/prisma.service.ts`

### Realtime Events

- [Events Module](https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/events/events.module.ts): `backend/backend/src/events/events.module.ts`
- [Socket.IO Gateway](https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/events/events.gateway.ts): `backend/backend/src/events/events.gateway.ts`

### Other components

- **HTTP Client**
- [Nest Bootstrap](https://github.com/adamakhiat/thermstream/blob/main/backend/backend/src/main.ts): `backend/backend/src/main.ts`
- **Kafka**
- **PostgreSQL**
- **Socket.IO Client**

## Connections

- Nest Bootstrap → Application Wiring: boots (evidence: `backend/backend/src/main.ts`)
- Application Wiring → Reading Module: imports (evidence: `backend/backend/src/app.module.ts`)
- Application Wiring → Prisma Module: imports (evidence: `backend/backend/src/app.module.ts`)
- Application Wiring → Kafka Client Setup: imports (evidence: `backend/backend/src/app.module.ts`)
- Application Wiring → Events Module: imports (evidence: `backend/backend/src/app.module.ts`)
- HTTP Client → Greeting Route: requests
- Greeting Route → Greeting Service: calls (evidence: `backend/backend/src/app.controller.ts`)
- HTTP Client → Reading Endpoint: posts readings
- Reading Endpoint → Reading Validation: validates with (evidence: `backend/backend/src/temp/temp.controller.ts`)
- Reading Endpoint → Kafka: publishes readings (evidence: `backend/backend/src/temp/temp.controller.ts`)
- Reading Endpoint → Kafka Client Setup: injects client
- Reading Module → Reading Endpoint: registers (evidence: `backend/backend/src/temp/temp.module.ts`)
- Reading Module → Batch Consumer: provides (evidence: `backend/backend/src/temp/temp.module.ts`)
- Reading Module → Kafka Client Setup: imports (evidence: `backend/backend/src/temp/temp.module.ts`)
- Batch Consumer → Kafka: consumes batches (evidence: `backend/backend/src/temp/temp.service.ts`)
- Batch Consumer → Prisma Client: writes readings (evidence: `backend/backend/src/temp/temp.service.ts`)
- Prisma Module → Prisma Client: provides (evidence: `backend/backend/src/prisma.module.ts`)
- Prisma Client → PostgreSQL: connects to (evidence: `backend/backend/src/prisma.service.ts`)
- Events Module → Socket.IO Gateway: provides (evidence: `backend/backend/src/events/events.module.ts`)
- Socket.IO Client → Socket.IO Gateway: connects (evidence: `backend/backend/src/events/events.gateway.ts`)
- Socket.IO Gateway → Socket.IO Client: emits messages (evidence: `backend/backend/src/events/events.gateway.ts`)
