# amgt2302/air-platformer architecture

> Architecture diagram of the GitHub repository amgt2302/air-platformer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/amgt2302/air-platformer
- Repository: https://github.com/amgt2302/air-platformer

## Overview

##### Project type and purpose
- AirPlatformer is a lightweight, full-stack web application: a real-time, multi-device platformer game.
- The “backend” is a single Node.js process (Server.js) that serves static front-end assets and hosts a WebSocket server.
- The “frontend” consists of two browser‐based clients:
- The “Controller” UI (controller.html + controller.js)
- The “Game” UI (game.html + game.js)

##### File structure
- Root:
- Server.js – Node.js entrypoint that both serves files over HTTP and handles WebSocket connections
- package.json/lock – Node dependencies (express, ws, etc.)
- public/ – all static assets
- HTML pages: index.html (landing), controller.html, game.html, setting.html
- public/JS: main.js (shared logic/bootstrap), controller.js, game.js, setting.js
- public/styles & style.css – CSS for each page
- public/asset – images and GIFs

##### README for additional insights
- Describes real-time multiplayer via WebSockets
- Two distinct client roles (controller vs. game screen) communicating through the server
- No external database—game state is managed in memory or on the clients

##### Detail without over-splitting
- Distinct role (landing page vs settings vs game) only if it adds clarity
- Real-time message flow (Pub/Sub WebSocket) as the core differentiator

[Controller Browser]
| HTTP GET /controller.html, JS, CSS
V
[Node.js HTTP Server]
|
+-----------------------------+
|                             |
V                             V
Serves static assets         [public/JS, public/styles, assets]
|
|
WebSocket Upgrade
|
V
[Node.js WebSocket Server]
^                 ^
| broadcasts      | broadcasts
| events          | events
|                 |
[Controller] ---> Server ---> [Game]
WS                WS          UI
^  <-----<-----<-----------<

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Clients
    subgraph "Frontend Clients"
        direction TB
        subgraph "Controller Browser" 
            direction TB
            ControllerHTML["controller.html"]:::frontend
            ControllerJS["controller.js"]:::frontend
            StyleController["styleController.css"]:::frontend
        end
        subgraph "Game Browser"
            direction TB
            GameHTML["game.html"]:::frontend
            GameJS["game.js"]:::frontend
            StyleGame["styleGame.css"]:::frontend
        end
        subgraph "Landing Page"
            direction TB
            LandingHTML["index.html"]:::frontend
            StyleLanding["style.css"]:::frontend
        end
        subgraph "Settings Page"
            direction TB
            SettingsHTML["setting.html"]:::frontend
            SettingsJS["setting.js"]:::frontend
            StyleSettings["style.css"]:::frontend
        end
        MainJS["main.js"]:::frontend
    end

    %% Backend Server
    subgraph "Server (Node.js)" 
        direction TB
        HTTP_Server["HTTP Server"]:::backend
        WS_Server["WebSocket Server"]:::backend
    end

    %% Static Assets & Configs
    Assets["Assets (images, GIFs)"]:::asset
    PackageJSON["package.json"]:::config
    PackageLock["package-lock.json"]:::config

    %% HTTP GET flows
    ControllerHTML -->|HTTP GET| HTTP_Server
    ControllerJS -->|HTTP GET| HTTP_Server
    StyleController -->|HTTP GET| HTTP_Server

    GameHTML -->|HTTP GET| HTTP_Server
    GameJS -->|HTTP GET| HTTP_Server
    StyleGame -->|HTTP GET| HTTP_Server

    LandingHTML -->|HTTP GET| HTTP_Server
    StyleLanding -->|HTTP GET| HTTP_Server

    SettingsHTML -->|HTTP GET| HTTP_Server
    SettingsJS -->|HTTP GET| HTTP_Server
    StyleSettings -->|HTTP GET| HTTP_Server

    MainJS -->|HTTP GET| HTTP_Server
    Assets -->|HTTP GET| HTTP_Server

    PackageJSON -->|Loaded at startup| HTTP_Server
    PackageLock -->|Loaded at startup| HTTP_Server

    %% HTTP to WebSocket upgrade
    HTTP_Server -->|Upgrade to WS| WS_Server

    %% WebSocket flows
    ControllerJS -->|WebSocket connect| WS_Server
    WS_Server -->|broadcast events| GameJS
    GameJS -->|WebSocket connect| WS_Server
    WS_Server -->|broadcast events| ControllerJS

    %% Click events
    click HTTP_Server "https://github.com/amgt2302/air-platformer/blob/main/Server.js"
    click WS_Server "https://github.com/amgt2302/air-platformer/blob/main/Server.js"
    click ControllerHTML "https://github.com/amgt2302/air-platformer/blob/main/public/controller.html"
    click ControllerJS "https://github.com/amgt2302/air-platformer/blob/main/public/JS/controller.js"
    click StyleController "https://github.com/amgt2302/air-platformer/blob/main/public/styles/styleController.css"
    click GameHTML "https://github.com/amgt2302/air-platformer/blob/main/public/game.html"
    click GameJS "https://github.com/amgt2302/air-platformer/blob/main/public/JS/game.js"
    click StyleGame "https://github.com/amgt2302/air-platformer/blob/main/public/styles/styleGame.css"
    click LandingHTML "https://github.com/amgt2302/air-platformer/blob/main/public/index.html"
    click StyleLanding "https://github.com/amgt2302/air-platformer/blob/main/public/style.css"
    click SettingsHTML "https://github.com/amgt2302/air-platformer/blob/main/public/setting.html"
    click SettingsJS "https://github.com/amgt2302/air-platformer/blob/main/public/JS/setting.js"
    click MainJS "https://github.com/amgt2302/air-platformer/blob/main/public/JS/main.js"
    click Assets "https://github.com/amgt2302/air-platformer/tree/main/public/asset/"
    click PackageJSON "https://github.com/amgt2302/air-platformer/blob/main/package.json"
    click PackageLock "https://github.com/amgt2302/air-platformer/blob/main/package-lock.json"

    %% Styling
    classDef frontend fill:#e0ffe0,stroke:#2d882d,stroke-width:1px
    classDef backend fill:#e0f0ff,stroke:#2266cc,stroke-width:1px
    classDef asset fill:#fff4e0,stroke:#cc6600,stroke-width:1px
    classDef config fill:#f0f0f0,stroke:#888888,stroke-width:1px
```
