# felipe-sabino-d-oliveira/grafana_lab architecture

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

- Interactive diagram: https://gitdiagram.com/felipe-sabino-d-oliveira/grafana_lab
- Repository: https://github.com/felipe-sabino-d-oliveira/grafana_lab

## Overview

Carnivorous Green House is a Flask app for user accounts and a simulated carnivorous-plant greenhouse, with live plant updates and a documented Alloy–Loki–Grafana logging stack. The main workflow is signup/login, view a user’s dashboard and plants, add plants over Socket.IO, and receive simulated readings. The only sampled runtime source is app.py; logging integrations are included from README documentation, so their edges reflect that documented flow rather than inspected configuration internals.

Main entry points: [`app.py`](https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/app.py) (Flask application), [`templates/dashboard.html`](https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/templates/dashboard.html) (Plant dashboard), [`alloy-config.alloy`](https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/alloy-config.alloy) (Grafana Alloy), [`loki-config.yaml`](https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/loki-config.yaml) (Grafana Loki)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web and accounts"]
  node_app["Flask application<br/>[app.py]"]
  node_auth["User authentication<br/>[app.py]"]
  node_userplant[("User and plant records<br/>[app.py]")]
end

subgraph group_plants["Greenhouse simulation"]
  node_dashboard["Plant dashboard<br/>[dashboard.html]"]
  node_plantentry["Plant registration<br/>[app.py]"]
  node_liveupdates["Live plant updates<br/>[app.py]"]
  node_failuremode["Random failure mode<br/>[app.py]"]
end

subgraph group_observability["Log observability"]
  node_logfile["Application log file<br/>[app.py]"]
  node_alloy["Grafana Alloy<br/>[alloy-config.alloy]"]
  node_loki[("Grafana Loki<br/>[loki-config.yaml]")]
  node_grafana["Grafana Explore<br/>[README.md]"]
end

node_visitor(("Visitor"))

node_visitor -->|"uses"| node_app
node_app -->|"routes auth"| node_auth
node_auth -->|"reads/writes"| node_userplant
node_app -->|"renders"| node_dashboard
node_dashboard -.->|"presents plants"| node_visitor
node_app -->|"handles events"| node_plantentry
node_plantentry -->|"writes plant"| node_userplant
node_app -->|"starts simulation"| node_liveupdates
node_liveupdates -->|"reads plants"| node_userplant
node_liveupdates -.->|"emits readings"| node_visitor
node_failuremode -->|"affects requests"| node_app
node_app -->|"writes logs"| node_logfile
node_logfile -->|"collects logs"| node_alloy
node_alloy -->|"forwards logs"| node_loki
node_grafana -->|"queries logs"| node_loki

click node_app "https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/app.py"
click node_auth "https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/app.py"
click node_userplant "https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/app.py"
click node_dashboard "https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/templates/dashboard.html"
click node_plantentry "https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/app.py"
click node_liveupdates "https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/app.py"
click node_failuremode "https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/app.py"
click node_logfile "https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/app.py"
click node_alloy "https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/alloy-config.alloy"
click node_loki "https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/loki-config.yaml"
click node_grafana "https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/README.md"

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_auth,node_userplant toneBlue
class node_dashboard,node_plantentry,node_liveupdates,node_failuremode toneAmber
class node_logfile,node_alloy,node_loki,node_grafana toneMint
class node_visitor toneIndigo
```

## Components

### Web and accounts

- [Flask application](https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/app.py): `app.py`
- [User authentication](https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/app.py): `app.py`
- [User and plant records](https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/app.py): `app.py`

### Greenhouse simulation

- [Plant dashboard](https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/templates/dashboard.html): `templates/dashboard.html`
- [Plant registration](https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/app.py): `app.py`
- [Live plant updates](https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/app.py): `app.py`
- [Random failure mode](https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/app.py): `app.py`

### Log observability

- [Application log file](https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/app.py): `app.py`
- [Grafana Alloy](https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/alloy-config.alloy): `alloy-config.alloy`
- [Grafana Loki](https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/loki-config.yaml): `loki-config.yaml`
- [Grafana Explore](https://github.com/felipe-sabino-d-oliveira/grafana_lab/blob/main/README.md): `README.md`

### Other components

- **Visitor**

## Connections

- Visitor → Flask application: uses (evidence: `README.md`)
- Flask application → User authentication: routes auth (evidence: `app.py`)
- User authentication → User and plant records: reads/writes (evidence: `app.py`)
- Flask application → Plant dashboard: renders (evidence: `app.py`)
- Plant dashboard → Visitor: presents plants
- Flask application → Plant registration: handles events (evidence: `app.py`)
- Plant registration → User and plant records: writes plant (evidence: `app.py`)
- Flask application → Live plant updates: starts simulation (evidence: `app.py`)
- Live plant updates → User and plant records: reads plants (evidence: `app.py`)
- Live plant updates → Visitor: emits readings
- Random failure mode → Flask application: affects requests (evidence: `app.py`)
- Flask application → Application log file: writes logs (evidence: `app.py`)
- Application log file → Grafana Alloy: collects logs (evidence: `README.md`)
- Grafana Alloy → Grafana Loki: forwards logs (evidence: `README.md`)
- Grafana Explore → Grafana Loki: queries logs (evidence: `README.md`)
