# litance/git-adventure architecture

> Architecture diagram of the GitHub repository litance/git-adventure, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/litance/git-adventure
- Repository: https://github.com/litance/git-adventure

## Overview

##### Project Type & Purpose
- That this is a client-side, static web game designed as an interactive learning experience.
- RPG elements (character creation, battles, story progression) integrated with Git tutorials.
- Recognize the deployment model is via GitHub Pages — meaning there is no backend server, and it's entirely based on static files.

##### Main Components
- Entry Point & Frontend:
- index.html acts as the main entry point.
- The css directory (with style.css) handles the styling and layout.
- The js directory houses all the game logic.

- JavaScript Modules (subdividing based on functionality):
- Game Core: js/game.js – orchestrates game state and overall flow.
- User Interface: js/ui.js – manages interactions and UI element updates.
- Audio: js/audio.js – handles game sounds.
- Story & Narrative: js/story.js – controls storyline and dialogue progression.
- Battles: js/battles.js – implements the combat system.
- Characters: js/characters.js – defines player and enemy attributes, possibly character progression.
- Git Command Simulation: js/gitCommands.js – simulates Git commands as game actions.
- Loading & Checks: js/loading-check.js – ensures resources are ready and the game loads correctly.

- Data Persistence:
- localStorage is used to store game progress locally, ensuring that state persists between sessions.

- External Environment:

##### Relationships & Interactions
- The browser loads index.html, which includes references to the CSS and JavaScript files.
- The UI layer (managed by ui.js) interacts with various game logic modules (game.js, battles.js, characters.js, story.js) to update the screen, handle user inputs, and display game progress.
- The audio.js module is invoked when triggered by events in the game (like battles or story developments).
- The gitCommands.js module translates user actions (picking Git commands) into game mechanics elements, interacting closely with the battle and game logic modules.
- using localStorage, changes made by these components (like game progress) are persisted.

##### Important Architectural Patterns & Design Principles
- Modular Design – each JavaScript file encapsulates a distinct aspect of the game, making it easier to extend functionality.
- Separation of Concerns – the structure clearly separates UI, game logic, audio, and data persistence.
- Client-Side Rendering – all components run on the client, which simplifies the architecture but requires careful handling of game state on the client side.

- From index.html to CSS and JS.
- From UI module to Game Logic and then to Battle or Story modules.
- From various game modules toward localStorage for saving progress.
- Another for business logic modules,
- And a distinct style for external services (GitHub Pages) and storage components.

##### Detail Without Overcomplicating
- Break the system into as many granular components as necessary based on the file tree.

## Diagram (Mermaid)

```mermaid
graph TD
    %% External Deployment
    GHP["GitHub Pages (Hosting)"]:::external

    %% Presentation Layer
    subgraph "Presentation Layer"
        EP["Entry Point (index.html)"]:::presentation
        CSS["CSS (style.css)"]:::presentation
    end

    %% Business Logic Layer
    subgraph "Application/Business Logic Layer"
        GC["Game Core (js/game.js)"]:::business
        UI["UI Module (js/ui.js)"]:::business
        AC["Audio Controller (js/audio.js)"]:::business
        SS["Story System (js/story.js)"]:::business
        BS["Battle System (js/battles.js)"]:::business
        CM["Character Management (js/characters.js)"]:::business
        GCE["Git Command Engine (js/gitCommands.js)"]:::business
        RL["Resource Loader (js/loading-check.js)"]:::business
    end

    %% Data Persistence Layer
    DP["Data Persistence (localStorage)"]:::data

    %% Relationships
    GHP -->|"serves"| EP
    EP -->|"loads"| CSS
    EP -->|"loads"| UI
    EP -->|"loads"| GC
    EP -->|"loads"| AC
    EP -->|"loads"| SS
    EP -->|"loads"| BS
    EP -->|"loads"| CM
    EP -->|"loads"| GCE
    EP -->|"loads"| RL

    UI -->|"triggers"| GC
    GC -->|"orchestrates"| BS
    GC -->|"orchestrates"| SS
    GC -->|"orchestrates"| CM
    GC -->|"orchestrates"| AC
    GC -->|"orchestrates"| GCE
    GC -->|"orchestrates"| RL
    GC -->|"persists"| DP

    GCE -->|"influences"| BS

    AC -->|"plays during"| BS
    AC -->|"plays during"| SS

    SS -->|"updates"| DP
    BS -->|"updates"| DP
    CM -->|"updates"| DP

    %% Click Events
    click EP "https://github.com/litance/git-adventure/blob/master/index.html"
    click CSS "https://github.com/litance/git-adventure/blob/master/css/style.css"
    click GC "https://github.com/litance/git-adventure/blob/master/js/game.js"
    click UI "https://github.com/litance/git-adventure/blob/master/js/ui.js"
    click AC "https://github.com/litance/git-adventure/blob/master/js/audio.js"
    click SS "https://github.com/litance/git-adventure/blob/master/js/story.js"
    click BS "https://github.com/litance/git-adventure/blob/master/js/battles.js"
    click CM "https://github.com/litance/git-adventure/blob/master/js/characters.js"
    click GCE "https://github.com/litance/git-adventure/blob/master/js/gitCommands.js"
    click RL "https://github.com/litance/git-adventure/blob/master/js/loading-check.js"

    %% Styles
    classDef presentation fill:#CEF6D8,stroke:#008000,stroke-width:2px;
    classDef business fill:#F6CEF6,stroke:#800080,stroke-width:2px;
    classDef data fill:#F6D8CE,stroke:#D2691E,stroke-width:2px;
    classDef external fill:#CEE7F6,stroke:#0000FF,stroke-width:2px;
```
