# juniorxxue/comp7503-tutorial-materials architecture

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

- Interactive diagram: https://gitdiagram.com/juniorxxue/comp7503-tutorial-materials
- Repository: https://github.com/juniorxxue/comp7503-tutorial-materials

## Overview

This repository packages a tutorial stack for polling Hong Kong Observatory (HKO) data, storing it in MongoDB, and displaying it in a Node-RED dashboard. The main workflow is: a student starts the stack, startup renders environment-specific settings into the demo flow, Node-RED polls HKO and updates the chart, and MongoDB provides persistent storage. The graph also shows documented setup, persistence, and first-boot user provisioning. Source excerpts are limited to Node-RED package and settings files; other relationships are based on the README, so implementation details beyond it are not inferred.

Main entry points: [`compose.yaml`](https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/compose.yaml) (Compose stack), [`scripts`](https://github.com/juniorxxue/comp7503-tutorial-materials/tree/main/scripts) (Start scripts), [`HKO.Flow.json`](https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/HKO.Flow.json) (HKO polling flow), [`nodered/entrypoint.sh`](https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/nodered/entrypoint.sh) (Node-RED entrypoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_operations["Stack operations"]
  node_start["Start scripts"]
  node_render["Flow renderer"]
  node_stop["Stop scripts"]
  node_reset["Reset scripts"]
end

subgraph group_flow["Node-RED flow"]
  node_sourceflow["Demo flow source<br/>[HKO.Flow.json]"]
  node_renderedflow["Rendered flow<br/>[flows.json]"]
  node_flowlogic["HKO polling flow<br/>[HKO.Flow.json]"]
  node_dashboard["Dashboard chart<br/>[HKO.Flow.json]"]
end

subgraph group_services["Runtime services"]
  node_compose["Compose stack<br/>[compose.yaml]"]
  node_entrypoint["Node-RED entrypoint<br/>[entrypoint.sh]"]
  node_noderuntime["Node-RED runtime<br/>[package.json]"]
  node_mongodb[("MongoDB service<br/>[compose.yaml]")]
  node_userinit["App-user initialization"]
end

subgraph group_state["Configuration and state"]
  node_env["Environment template<br/>[.env.example]"]
  node_dbstate[("MongoDB data volume<br/>[compose.yaml]")]
  node_nrstate[("Node-RED data volume<br/>[compose.yaml]")]
end

node_student(("Student"))
node_hko["HKO service"]

node_student -->|"starts stack"| node_start
node_start -->|"creates if missing"| node_env
node_start -->|"runs"| node_render
node_render -->|"reads"| node_sourceflow
node_render -->|"reads settings"| node_env
node_render -->|"renders"| node_renderedflow
node_start -->|"starts"| node_compose
node_compose -->|"starts service"| node_entrypoint
node_entrypoint -->|"seeds flow"| node_renderedflow
node_entrypoint -->|"launches"| node_noderuntime
node_noderuntime -->|"runs"| node_flowlogic
node_flowlogic -->|"polls"| node_hko
node_flowlogic -->|"stores data"| node_mongodb
node_flowlogic -->|"updates chart"| node_dashboard
node_compose -->|"starts service"| node_mongodb
node_mongodb -->|"initializes user"| node_userinit
node_mongodb -->|"persists data"| node_dbstate
node_entrypoint -->|"seeds persistent data"| node_nrstate
node_compose -->|"configures service"| node_noderuntime
node_student -->|"stops stack"| node_stop
node_student -->|"resets stack"| node_reset
node_stop -->|"stops services"| node_compose
node_reset -->|"removes volume"| node_dbstate
node_reset -->|"removes volume"| node_nrstate

click node_start "https://github.com/juniorxxue/comp7503-tutorial-materials/tree/main/scripts"
click node_render "https://github.com/juniorxxue/comp7503-tutorial-materials/tree/main/scripts"
click node_stop "https://github.com/juniorxxue/comp7503-tutorial-materials/tree/main/scripts"
click node_reset "https://github.com/juniorxxue/comp7503-tutorial-materials/tree/main/scripts"
click node_env "https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/.env.example"
click node_compose "https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/compose.yaml"
click node_sourceflow "https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/HKO.Flow.json"
click node_renderedflow "https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/nodered/flows.json"
click node_entrypoint "https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/nodered/entrypoint.sh"
click node_noderuntime "https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/nodered/package.json"
click node_flowlogic "https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/HKO.Flow.json"
click node_dashboard "https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/HKO.Flow.json"
click node_mongodb "https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/compose.yaml"
click node_userinit "https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/mongodb/init/01-create-app-user.sh"
click node_dbstate "https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/compose.yaml"
click node_nrstate "https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/compose.yaml"

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_start,node_render,node_stop,node_reset toneBlue
class node_sourceflow,node_renderedflow,node_flowlogic,node_dashboard toneAmber
class node_compose,node_entrypoint,node_noderuntime,node_mongodb,node_userinit toneMint
class node_env,node_dbstate,node_nrstate toneRose
class node_student,node_hko toneIndigo
```

## Components

### Stack operations

- [Start scripts](https://github.com/juniorxxue/comp7503-tutorial-materials/tree/main/scripts): `scripts`
- [Flow renderer](https://github.com/juniorxxue/comp7503-tutorial-materials/tree/main/scripts): `scripts`
- [Stop scripts](https://github.com/juniorxxue/comp7503-tutorial-materials/tree/main/scripts): `scripts`
- [Reset scripts](https://github.com/juniorxxue/comp7503-tutorial-materials/tree/main/scripts): `scripts`

### Node-RED flow

- [Demo flow source](https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/HKO.Flow.json): `HKO.Flow.json`
- [Rendered flow](https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/nodered/flows.json): `nodered/flows.json`
- [HKO polling flow](https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/HKO.Flow.json): `HKO.Flow.json`
- [Dashboard chart](https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/HKO.Flow.json): `HKO.Flow.json`

### Runtime services

- [Compose stack](https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/compose.yaml): `compose.yaml`
- [Node-RED entrypoint](https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/nodered/entrypoint.sh): `nodered/entrypoint.sh`
- [Node-RED runtime](https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/nodered/package.json): `nodered/package.json`
- [MongoDB service](https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/compose.yaml): `compose.yaml`
- [App-user initialization](https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/mongodb/init/01-create-app-user.sh): `mongodb/init/01-create-app-user.sh`

### Configuration and state

- [Environment template](https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/.env.example): `.env.example`
- [MongoDB data volume](https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/compose.yaml): `compose.yaml`
- [Node-RED data volume](https://github.com/juniorxxue/comp7503-tutorial-materials/blob/main/compose.yaml): `compose.yaml`

### Other components

- **Student**
- **HKO service**

## Connections

- Student → Start scripts: starts stack (evidence: `README.md`)
- Start scripts → Environment template: creates if missing (evidence: `README.md`)
- Start scripts → Flow renderer: runs (evidence: `README.md`)
- Flow renderer → Demo flow source: reads (evidence: `README.md`)
- Flow renderer → Environment template: reads settings (evidence: `README.md`)
- Flow renderer → Rendered flow: renders (evidence: `README.md`)
- Start scripts → Compose stack: starts (evidence: `README.md`)
- Compose stack → Node-RED entrypoint: starts service (evidence: `README.md`)
- Node-RED entrypoint → Rendered flow: seeds flow (evidence: `README.md`)
- Node-RED entrypoint → Node-RED runtime: launches (evidence: `README.md`)
- Node-RED runtime → HKO polling flow: runs (evidence: `README.md`)
- HKO polling flow → HKO service: polls (evidence: `README.md`)
- HKO polling flow → MongoDB service: stores data (evidence: `README.md`)
- HKO polling flow → Dashboard chart: updates chart (evidence: `README.md`)
- Compose stack → MongoDB service: starts service (evidence: `README.md`)
- MongoDB service → App-user initialization: initializes user (evidence: `README.md`)
- MongoDB service → MongoDB data volume: persists data (evidence: `README.md`)
- Node-RED entrypoint → Node-RED data volume: seeds persistent data (evidence: `README.md`)
- Compose stack → Node-RED runtime: configures service (evidence: `README.md`)
- Student → Stop scripts: stops stack (evidence: `README.md`)
- Student → Reset scripts: resets stack (evidence: `README.md`)
- Stop scripts → Compose stack: stops services (evidence: `README.md`)
- Reset scripts → MongoDB data volume: removes volume (evidence: `README.md`)
- Reset scripts → Node-RED data volume: removes volume (evidence: `README.md`)
