# uaigoiano-max/drinkfornetwifi architecture

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

- Interactive diagram: https://gitdiagram.com/uaigoiano-max/drinkfornetwifi
- Repository: https://github.com/uaigoiano-max/drinkfornetwifi

## Overview

DrinkForNet is a portable event Wi-Fi captive-portal product: visitors learn the access rule, meet the host, receive an individual voucher, and use it for a 25-minute session. Its runtime spans a static visitor experience and an OpenWrt voucher core with an administrative interface. The sampled sources show the page configuration and browser behavior, plus the admin client’s CGI requests. README claims cover the core’s lifecycle and the still-unimplemented network authorization adapter; those unsampled connections are represented cautiously.

Main entry points: [`script.js`](https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/script.js) (Page interactions), [`openwrt/usr/libexec/drinkfornet-core.lua`](https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/openwrt/usr/libexec/drinkfornet-core.lua) (Voucher core), [`wifi-free.html`](https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/wifi-free.html) (Captive landing page), [`admin/admin.js`](https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/admin/admin.js) (Admin console)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_visitor["Visitor experience"]
  node_landing["Captive landing page<br/>[wifi-free.html]"]
  node_page_behavior["Page interactions<br/>[script.js]"]
  node_event_config["Event configuration<br/>[config.js]"]
  node_photo_gallery["Host photo gallery<br/>[script.js]"]
  node_voucher_form["Voucher form<br/>[wifi-free.html]"]
end

subgraph group_voucher["Voucher operations"]
  node_admin_console["Admin console<br/>[admin.js]"]
  node_admin_api["Admin CGI API<br/>[drinkfornet.lua]"]
  node_voucher_core["Voucher core"]
  node_voucher_store[("Persistent voucher store")]
  node_voucher_lifecycle["Voucher lifecycle"]
end

subgraph group_network["Network access"]
  node_router{{"OpenWrt router"}}
  node_network_adapter["Network adapter"]
  node_firewall["Firewall authorization"]
end

node_visitor(("Event visitor"))
node_admin_user(("Event administrator"))

node_visitor -->|"opens"| node_landing
node_landing -->|"runs interactions"| node_page_behavior
node_page_behavior -->|"reads settings"| node_event_config
node_page_behavior -->|"renders gallery"| node_photo_gallery
node_visitor -->|"enters voucher"| node_voucher_form
node_admin_user -->|"manages vouchers"| node_admin_console
node_admin_console -->|"requests actions"| node_admin_api
node_admin_api -.->|"delegates operations"| node_voucher_core
node_voucher_core -.->|"persists vouchers"| node_voucher_store
node_voucher_core -->|"generates and expires"| node_voucher_lifecycle
node_router -->|"opens portal"| node_landing
node_network_adapter -.->|"would authorize"| node_firewall
node_voucher_lifecycle -.->|"would activate access"| node_network_adapter

click node_landing "https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/wifi-free.html"
click node_page_behavior "https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/script.js"
click node_event_config "https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/config.js"
click node_photo_gallery "https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/script.js"
click node_voucher_form "https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/wifi-free.html"
click node_admin_console "https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/admin/admin.js"
click node_admin_api "https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/openwrt/www/cgi-bin/drinkfornet.lua"
click node_voucher_core "https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/openwrt/usr/libexec/drinkfornet-core.lua"
click node_voucher_store "https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/openwrt/usr/libexec/drinkfornet-core.lua"
click node_voucher_lifecycle "https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/openwrt/usr/libexec/drinkfornet-core.lua"
click node_network_adapter "https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/openwrt/usr/sbin/drinkfornet-adapter"

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_landing,node_page_behavior,node_event_config,node_photo_gallery,node_voucher_form toneBlue
class node_admin_console,node_admin_api,node_voucher_core,node_voucher_store,node_voucher_lifecycle toneAmber
class node_router,node_network_adapter,node_firewall toneMint
class node_visitor,node_admin_user toneIndigo
```

## Components

### Visitor experience

- [Captive landing page](https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/wifi-free.html): `wifi-free.html`
- [Page interactions](https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/script.js): `script.js`
- [Event configuration](https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/config.js): `config.js`
- [Host photo gallery](https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/script.js): `script.js`
- [Voucher form](https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/wifi-free.html): `wifi-free.html`

### Voucher operations

- [Admin console](https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/admin/admin.js): `admin/admin.js`
- [Admin CGI API](https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/openwrt/www/cgi-bin/drinkfornet.lua): `openwrt/www/cgi-bin/drinkfornet.lua`
- [Voucher core](https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/openwrt/usr/libexec/drinkfornet-core.lua): `openwrt/usr/libexec/drinkfornet-core.lua`
- [Persistent voucher store](https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/openwrt/usr/libexec/drinkfornet-core.lua): `openwrt/usr/libexec/drinkfornet-core.lua`
- [Voucher lifecycle](https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/openwrt/usr/libexec/drinkfornet-core.lua): `openwrt/usr/libexec/drinkfornet-core.lua`

### Network access

- **OpenWrt router**
- [Network adapter](https://github.com/uaigoiano-max/drinkfornetwifi/blob/main/openwrt/usr/sbin/drinkfornet-adapter): `openwrt/usr/sbin/drinkfornet-adapter`
- **Firewall authorization**

### Other components

- **Event visitor**
- **Event administrator**

## Connections

- Event visitor → Captive landing page: opens (evidence: `README.md`)
- Captive landing page → Page interactions: runs interactions (evidence: `script.js`)
- Page interactions → Event configuration: reads settings (evidence: `script.js`)
- Page interactions → Host photo gallery: renders gallery (evidence: `script.js`)
- Event visitor → Voucher form: enters voucher (evidence: `README.md`)
- Event administrator → Admin console: manages vouchers (evidence: `README.md`)
- Admin console → Admin CGI API: requests actions (evidence: `admin/admin.js`)
- Admin CGI API → Voucher core: delegates operations
- Voucher core → Persistent voucher store: persists vouchers
- Voucher core → Voucher lifecycle: generates and expires (evidence: `README.md`)
- OpenWrt router → Captive landing page: opens portal (evidence: `README.md`)
- Network adapter → Firewall authorization: would authorize (evidence: `README.md`)
- Voucher lifecycle → Network adapter: would activate access (evidence: `README.md`)
