# waeel1937/full-stack-go-sveltekit-sqlite-template architecture

> Architecture diagram of the GitHub repository waeel1937/full-stack-go-sveltekit-sqlite-template, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/waeel1937/full-stack-go-sveltekit-sqlite-template
- Repository: https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template

## Overview

This is a full-stack industrial IoT edge template: connectors or a demo producer publish sensor readings, the backend aggregates them locally and evaluates threshold rules, then persists results and serves the UI through REST and SSE. The frontend supports live dashboard data, alerts, and rule management; documented capabilities also include Keycloak authentication, Prometheus metrics, and selective cloud sync. Source excerpts establish startup wiring and selected calls; other relationships below are based on the README architecture, not unsampled implementation details.

Main entry points: [`edge-app/internal/core/bus.go`](https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/core/bus.go) (Event Bus), [`frontend/src/lib/stores/api.js`](https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/frontend/src/lib/stores/api.js) (Frontend API Store), [`edge-app/internal/storage/sqlite.go`](https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/storage/sqlite.go) (SQLite Store), [`edge-app/internal/api/http.go`](https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/api/http.go) (HTTP API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Sensor Ingestion"]
  node_modbus["Modbus TCP<br/>[modbus.go]"]
  node_opcua["OPC-UA<br/>[opcua.go]"]
  node_demo["Demo Producer<br/>[main.go]"]
end

subgraph group_processing["Edge Processing"]
  node_bus["Event Bus<br/>[bus.go]"]
  node_aggregator["Window Aggregator<br/>[aggregator.go]"]
  node_raw["Raw Capture<br/>[raw_capture.go]"]
  node_ring[("Ring Buffer<br/>[buffer.go]")]
  node_rules["Rule Engine<br/>[rules.go]"]
  node_store[("SQLite Store<br/>[sqlite.go]")]
  node_persister["Aggregate Persister<br/>[persist.go]"]
end

subgraph group_services["Backend Services"]
  node_cloudsync["Cloud Sync<br/>[cloud.go]"]
  node_api["HTTP API<br/>[http.go]"]
  node_metrics["Prometheus Metrics<br/>[prometheus.go]"]
  node_grpc["gRPC Streaming"]
end

subgraph group_client["User Interface"]
  node_frontendapi["Frontend API Store<br/>[api.js]"]
  node_layout["App Shell<br/>[+layout.svelte]"]
  node_dashboard["Dashboard<br/>[+page.svelte]"]
  node_alerts["Alerts View<br/>[+page.svelte]"]
  node_rulesui["Rules View<br/>[+page.svelte]"]
end

node_operator(("Operator"))
node_cloud["Cloud Endpoint"]
node_keycloak["Keycloak<br/>[edge-realm.json]"]

node_operator -->|"uses"| node_layout
node_modbus -->|"publishes metrics"| node_bus
node_opcua -->|"publishes metrics"| node_bus
node_demo -->|"publishes metrics"| node_bus
node_bus -->|"fans out metrics"| node_aggregator
node_bus -->|"fans out metrics"| node_raw
node_raw -->|"captures samples"| node_ring
node_aggregator -->|"publishes aggregates"| node_bus
node_bus -->|"delivers aggregates"| node_persister
node_persister -->|"writes aggregates"| node_store
node_bus -->|"delivers aggregates"| node_rules
node_rules -->|"publishes alerts"| node_bus
node_rules -->|"loads and saves rules"| node_store
node_store -->|"supplies aggregates"| node_cloudsync
node_cloudsync -->|"posts summaries"| node_cloud
node_bus -->|"streams events"| node_api
node_store -->|"serves aggregate queries"| node_api
node_api -->|"fetches signing keys"| node_keycloak
node_frontendapi -->|"requests REST and SSE"| node_api
node_frontendapi -->|"authenticates users"| node_keycloak
node_layout -->|"starts stream"| node_frontendapi
node_dashboard -->|"reads live data"| node_frontendapi
node_alerts -->|"reads alert state"| node_frontendapi
node_rulesui -->|"manages rules"| node_frontendapi
node_operator -->|"configures thresholds"| node_rulesui
node_operator -->|"reviews alerts"| node_alerts
node_operator -->|"views live metrics"| node_dashboard

click node_modbus "https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/connector/modbus.go"
click node_opcua "https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/connector/opcua.go"
click node_demo "https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/cmd/edge-app/main.go"
click node_bus "https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/core/bus.go"
click node_aggregator "https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/aggregator/aggregator.go"
click node_raw "https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/aggregator/raw_capture.go"
click node_ring "https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/storage/ringbuffer/buffer.go"
click node_rules "https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/rules/rules.go"
click node_store "https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/storage/sqlite.go"
click node_persister "https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/aggregator/persist.go"
click node_cloudsync "https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/sync/cloud.go"
click node_api "https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/api/http.go"
click node_metrics "https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/metrics/prometheus.go"
click node_keycloak "https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/config/keycloak/edge-realm.json"
click node_grpc "https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/tree/main/edge-app/internal/api"
click node_frontendapi "https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/frontend/src/lib/stores/api.js"
click node_layout "https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/frontend/src/routes/%2Blayout.svelte"
click node_dashboard "https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/frontend/src/routes/%2Bpage.svelte"
click node_alerts "https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/frontend/src/routes/alerts/%2Bpage.svelte"
click node_rulesui "https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/frontend/src/routes/rules/%2Bpage.svelte"

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_modbus,node_opcua,node_demo toneBlue
class node_bus,node_aggregator,node_raw,node_ring,node_rules,node_store,node_persister toneAmber
class node_cloudsync,node_api,node_metrics,node_grpc toneMint
class node_frontendapi,node_layout,node_dashboard,node_alerts,node_rulesui toneRose
class node_operator,node_cloud toneIndigo
class node_keycloak toneTeal
```

## Components

### Sensor Ingestion

- [Modbus TCP](https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/connector/modbus.go): `edge-app/internal/connector/modbus.go`
- [OPC-UA](https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/connector/opcua.go): `edge-app/internal/connector/opcua.go`
- [Demo Producer](https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/cmd/edge-app/main.go): `edge-app/cmd/edge-app/main.go`

### Edge Processing

- [Event Bus](https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/core/bus.go): `edge-app/internal/core/bus.go`
- [Window Aggregator](https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/aggregator/aggregator.go): `edge-app/internal/aggregator/aggregator.go`
- [Raw Capture](https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/aggregator/raw_capture.go): `edge-app/internal/aggregator/raw_capture.go`
- [Ring Buffer](https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/storage/ringbuffer/buffer.go): `edge-app/internal/storage/ringbuffer/buffer.go`
- [Rule Engine](https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/rules/rules.go): `edge-app/internal/rules/rules.go`
- [SQLite Store](https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/storage/sqlite.go): `edge-app/internal/storage/sqlite.go`
- [Aggregate Persister](https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/aggregator/persist.go): `edge-app/internal/aggregator/persist.go`

### Backend Services

- [Cloud Sync](https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/sync/cloud.go): `edge-app/internal/sync/cloud.go`
- [HTTP API](https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/api/http.go): `edge-app/internal/api/http.go`
- [Prometheus Metrics](https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/edge-app/internal/metrics/prometheus.go): `edge-app/internal/metrics/prometheus.go`
- [gRPC Streaming](https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/tree/main/edge-app/internal/api): `edge-app/internal/api`

### User Interface

- [Frontend API Store](https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/frontend/src/lib/stores/api.js): `frontend/src/lib/stores/api.js`
- [App Shell](https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/frontend/src/routes/%2Blayout.svelte): `frontend/src/routes/+layout.svelte`
- [Dashboard](https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/frontend/src/routes/%2Bpage.svelte): `frontend/src/routes/+page.svelte`
- [Alerts View](https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/frontend/src/routes/alerts/%2Bpage.svelte): `frontend/src/routes/alerts/+page.svelte`
- [Rules View](https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/frontend/src/routes/rules/%2Bpage.svelte): `frontend/src/routes/rules/+page.svelte`

### Other components

- **Operator**
- **Cloud Endpoint**
- [Keycloak](https://github.com/waeel1937/full-stack-go-sveltekit-sqlite-template/blob/main/config/keycloak/edge-realm.json): `config/keycloak/edge-realm.json`

## Connections

- Operator → App Shell: uses (evidence: `README.md`)
- Modbus TCP → Event Bus: publishes metrics (evidence: `README.md`)
- OPC-UA → Event Bus: publishes metrics (evidence: `README.md`)
- Demo Producer → Event Bus: publishes metrics (evidence: `edge-app/cmd/edge-app/main.go`)
- Event Bus → Window Aggregator: fans out metrics (evidence: `README.md`)
- Event Bus → Raw Capture: fans out metrics (evidence: `README.md`)
- Raw Capture → Ring Buffer: captures samples
- Window Aggregator → Event Bus: publishes aggregates (evidence: `README.md`)
- Event Bus → Aggregate Persister: delivers aggregates (evidence: `README.md`)
- Aggregate Persister → SQLite Store: writes aggregates (evidence: `README.md`)
- Event Bus → Rule Engine: delivers aggregates (evidence: `README.md`)
- Rule Engine → Event Bus: publishes alerts (evidence: `edge-app/internal/rules/rules.go`)
- Rule Engine → SQLite Store: loads and saves rules (evidence: `edge-app/internal/rules/rules.go`)
- SQLite Store → Cloud Sync: supplies aggregates (evidence: `README.md`)
- Cloud Sync → Cloud Endpoint: posts summaries (evidence: `README.md`)
- Event Bus → HTTP API: streams events (evidence: `edge-app/internal/api/http.go`)
- SQLite Store → HTTP API: serves aggregate queries (evidence: `README.md`)
- HTTP API → Keycloak: fetches signing keys (evidence: `edge-app/internal/api/http.go`)
- Frontend API Store → HTTP API: requests REST and SSE (evidence: `README.md`)
- Frontend API Store → Keycloak: authenticates users (evidence: `README.md`)
- App Shell → Frontend API Store: starts stream (evidence: `frontend/src/routes/+layout.svelte`)
- Dashboard → Frontend API Store: reads live data (evidence: `README.md`)
- Alerts View → Frontend API Store: reads alert state (evidence: `README.md`)
- Rules View → Frontend API Store: manages rules (evidence: `frontend/src/routes/rules/+page.svelte`)
- Operator → Rules View: configures thresholds (evidence: `README.md`)
- Operator → Alerts View: reviews alerts (evidence: `README.md`)
- Operator → Dashboard: views live metrics (evidence: `README.md`)
