# openwisp/openwisp-wifi-login-pages architecture

> Architecture diagram of the GitHub repository openwisp/openwisp-wifi-login-pages, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/openwisp/openwisp-wifi-login-pages
- Repository: https://github.com/openwisp/openwisp-wifi-login-pages

## Overview

##### Project type and purpose
- This is a full-stack web application (“openwisp-wifi-login-pages”) that replaces captive-portal login pages with a unified React-based SPA front end and a Node.js/Express back end.
- It integrates with an external OpenWISP Radius API to authenticate and authorize WiFi users, and it supports organization-specific theming via template files under the “organizations” directory.

##### File structure
- Top-level directories:
- client/ – React SPA (actions, reducers, components, styles, tests)
- server/ – Express app (controllers, routes, utils, start script, tests)
- config/ – build & test configuration (webpack, Jest)
- internals/ – generators for scaffolding new organizations
- organizations/ – per-organization static JS/CSS and YAML config
- i18n/ – translation catalogs
- browser-test/ – Python and JS end-to-end test scripts
- docs/ – user and developer guides
- Architectural patterns:
- Front-end uses Flux/Redux (actions → dispatchers → reducers → store → React components)
- Back-end follows MVC-style organization (routes → controller → utils/external API)
- Build pipeline driven by Webpack, Babel, configuration scripts

##### README for additional insights
- Confirms the SPA + API split, integration with the OpenWISP Radius API, multi-language support, theming per organization, and CI/testing workflow.

##### Components
1. User Device (Browser)
2. Static Asset Delivery (e.g., CDN / Express static middleware serving public/ + organizations/*/client_assets)
3. Front-end SPA (React + Redux)
4. Back-end API (Node.js + Express controllers & routes)
5. External OpenWISP Radius API
6. Build & Config Subsystem (Webpack, Babel, config scripts, internals/generators)
7. Translation subsystem (i18n catalogs loaded at build/runtime)
8. Test Harness (Jest unit tests + Python-based browser-test suite)

- User Device → Static Asset Delivery → SPA
- SPA → Back-end API (REST calls for login, registration, password reset, mobile verification, payments)
- Back-end API → External Radius API (authenticate, obtain tokens, user-session management)
- Build & Config Subsystem → generates static assets (invoked pre-deploy)
- i18n subsystem → feeds translations into SPA at build/runtime
- Test Harness ↔ SPA and API (unit tests against client/, server/tests/, browser-test scripts)

c. Architectural patterns & principles:
- Separation of concerns: distinct front-end SPA layer vs. back-end API layer
- Flux/Redux data flow on the client
- MVC-style controllers & routes on the server
- Plugin-style theming: “organizations” folder supplies client_assets & server_assets per org
- Build-time code generation: “internals/generators” scaffolds new org templates

d. Key technologies & frameworks:
- React, Redux, React Router
- Node.js, Express
- Webpack, Babel
- Jest (unit tests), Python (browser-test E2E)
- i18next or custom i18n loader (PO files in i18n/)
- Docker/Nginx (optional in deployment, though not in this repo)

##### Detail
- Per-organization theming, translation loading, CI/test flow

## Diagram (Mermaid)

```mermaid
graph TD
  subgraph "Runtime Components"
    Browser["User Device (Browser)"]:::runtime
    Static["Static Asset Delivery"]:::runtime
    SPA["Front-end SPA (React + Redux)"]:::runtime
    API["Back-end API (Node.js + Express)"]:::runtime
    ExtAPI["External OpenWISP Radius API"]:::runtime
  end

  subgraph "Build & Config Subsystem"
    Build["Build & Config (Webpack, Babel, scripts)"]:::build
    Gen["Organization Generators"]:::build
  end

  subgraph "Translation Subsystem"
    I18n["i18n Catalogs (.po files)"]:::build
  end

  subgraph "Test Harness"
    Jest["Jest Unit Tests"]:::tests
    E2E["Browser E2E Tests"]:::tests
  end

  Browser -->|"HTTP GET /bundle.js"| Static
  Static --> SPA
  SPA -->|"REST API Calls"| API
  API -->|"POST /authenticate"| ExtAPI
  Build --> SPA
  I18n --> SPA
  Jest --> SPA
  Jest --> API
  E2E --> SPA
  E2E --> API

  click Static "https://github.com/openwisp/openwisp-wifi-login-pages/blob/master/public/index.html"
  click Static "https://github.com/openwisp/openwisp-wifi-login-pages/blob/master/organizations/default/client_assets/index.js"
  click Static "https://github.com/openwisp/openwisp-wifi-login-pages/blob/master/organizations/default/client_assets/index.css"
  click SPA "https://github.com/openwisp/openwisp-wifi-login-pages/blob/master/client/index.js"
  click SPA "https://github.com/openwisp/openwisp-wifi-login-pages/blob/master/client/app.js"
  click SPA "https://github.com/openwisp/openwisp-wifi-login-pages/blob/master/client/routes.js"
  click SPA "https://github.com/openwisp/openwisp-wifi-login-pages/tree/master/client/actions/"
  click SPA "https://github.com/openwisp/openwisp-wifi-login-pages/tree/master/client/reducers/"
  click SPA "https://github.com/openwisp/openwisp-wifi-login-pages/tree/master/client/store/"
  click SPA "https://github.com/openwisp/openwisp-wifi-login-pages/tree/master/client/components/"
  click SPA "https://github.com/openwisp/openwisp-wifi-login-pages/tree/master/client/constants/"
  click SPA "https://github.com/openwisp/openwisp-wifi-login-pages/tree/master/client/utils/"
  click API "https://github.com/openwisp/openwisp-wifi-login-pages/blob/master/server/start.js"
  click API "https://github.com/openwisp/openwisp-wifi-login-pages/blob/master/server/index.js"
  click API "https://github.com/openwisp/openwisp-wifi-login-pages/tree/master/server/routes/"
  click API "https://github.com/openwisp/openwisp-wifi-login-pages/tree/master/server/controllers/"
  click API "https://github.com/openwisp/openwisp-wifi-login-pages/tree/master/server/utils/"
  click API "https://github.com/openwisp/openwisp-wifi-login-pages/blob/master/server/morganMiddleware.js"
  click ExtAPI "https://github.com/openwisp/openwisp-wifi-login-pages/blob/master/server/utils/openwisp-urls.js"
  click ExtAPI "https://github.com/openwisp/openwisp-wifi-login-pages/blob/master/server/utils/send-cookies.js"
  click ExtAPI "https://github.com/openwisp/openwisp-wifi-login-pages/blob/master/server/utils/default-config.js"
  click Build "https://github.com/openwisp/openwisp-wifi-login-pages/blob/master/babel.config.js"
  click Build "https://github.com/openwisp/openwisp-wifi-login-pages/blob/master/config/webpack.config.js"
  click Build "https://github.com/openwisp/openwisp-wifi-login-pages/blob/master/config/add-org.js"
  click Build "https://github.com/openwisp/openwisp-wifi-login-pages/blob/master/config/build-translations.js"
  click Gen "https://github.com/openwisp/openwisp-wifi-login-pages/tree/master/internals/generators/"
  click I18n "https://github.com/openwisp/openwisp-wifi-login-pages/blob/master/i18n/en.po"
  click I18n "https://github.com/openwisp/openwisp-wifi-login-pages/blob/master/config/build-translations.js"
  click Jest "https://github.com/openwisp/openwisp-wifi-login-pages/tree/master/client/actions/__tests__"
  click Jest "https://github.com/openwisp/openwisp-wifi-login-pages/tree/master/server/tests/"
  click E2E "https://github.com/openwisp/openwisp-wifi-login-pages/tree/master/browser-test/"

  classDef runtime fill:#cce5ff,stroke:#004085,color:#004085
  classDef build fill:#d4edda,stroke:#155724,color:#155724
  classDef tests fill:none,stroke:#856404,stroke-dasharray:5 5,color:#856404
```
