# todomagichere/quizzity architecture

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

- Interactive diagram: https://gitdiagram.com/todomagichere/quizzity
- Repository: https://github.com/todomagichere/quizzity

## Overview

##### Project Identification
- This is a client-side web application—a geographical quiz game (Capital mode) built on top of a Leaflet map.
- The core purpose is to let users guess the location of cities using an interactive map. The gameplay revolves around accuracy and speed in placing guesses.

##### Main Components
a. User Interface:
- HTML pages (index.html and index_es.html) serve as the starting points.
- CSS assets (css/quizzity.css and libraries like Animate.css, Font Awesome) for styling.
b. JavaScript Logic:
- Core quiz logic in the JS files (js/quizzity.js and js/quizzity_es.js).
- Integration of third-party libraries: Leaflet for the map, jQuery for DOM manipulation, lodash for utility functions, Leaflet.awesome-markers for custom markers, and Leaflet.Geodesic for geodesic lines.
c. And Geospatial Data:
- The Leaflet-based map that integrates:
- Tiles stored in a hierarchically structured “tiles” directory (organized by zoom levels and coordinates).
- Geodata JSON files (in the geodata directory) that include city and capital information in different languages (EN/ES).
d. Third-Party Libraries/Components:
- The “bower_components” folder, which includes all external libraries and resources necessary for the map and UI (Leaflet, animate.css, jquery, etc.).

##### Relationships and Interactions
- The user interacts with the HTML pages which load the CSS for styling and JavaScript for interactivity.
- The JavaScript files (quizzity.js and its localized version) initialize the Leaflet map and load the corresponding geodata JSON files.
- The map component pulls tiles from the “tiles” directory based on user interactions (zoom and pan).

##### Architectural Patterns and Design Principles
- Client-Side Focus: The entire logic is executed within the browser. There is minimal back-end interaction since the game is a static web app.
- Separation of Concerns: UI (HTML/CSS) is separate from business logic (JS) and data (geodata JSON and map tiles).
- Modularization: The project makes use of external libraries (organized in bower_components) to modularize functionality.

## Diagram (Mermaid)

```mermaid
flowchart TD
    App["Quizzity – Capital Mode Application"]:::app

    subgraph "Frontend/UI Layer"
        HTML1["index.html"]:::frontend
        HTML2["index_es.html"]:::frontend
        CSS["css/quizzity.css"]:::frontend
        Icons["Icons/Images"]:::frontend
        JS1["js/quizzity.js"]:::frontend
        JS2["js/quizzity_es.js"]:::frontend
    end

    subgraph "Map Rendering & Data Resources"
        subgraph "Map Tiles"
            Tile2["tiles/2"]:::map
            Tile3["tiles/3"]:::map
            Tile4["tiles/4"]:::map
            Tile5["tiles/5"]:::map
        end
        subgraph "Geospatial Data"
            GeoEN["geodata/cities-capitals_en.json"]:::map
            GeoES["geodata/cities-capitals_es.json"]:::map
        end
    end

    subgraph "Third-Party Libraries/Dependencies"
        Leaflet["Leaflet"]:::tp
        jQuery["jQuery"]:::tp
        Lodash["lodash"]:::tp
        Markers["Leaflet.awesome-markers"]:::tp
        Geodesic["Leaflet.Geodesic"]:::tp
        Animate["animate.css"]:::tp
        FontAwesome["font-awesome"]:::tp
        Bower["bower_components"]:::tp
    end

    %% Application relationships
    HTML1 -->|"loads"| CSS
    HTML2 -->|"loads"| CSS
    HTML1 -->|"loads"| JS1
    HTML2 -->|"loads"| JS2

    JS1 -->|"initMap"| Leaflet
    JS2 -->|"initMap"| Leaflet
    JS1 -->|"calls"| jQuery
    JS2 -->|"calls"| jQuery
    JS1 -->|"calls"| Lodash
    JS2 -->|"calls"| Lodash

    Leaflet -->|"renders"| Tile2
    Leaflet -->|"renders"| Tile3
    Leaflet -->|"renders"| Tile4
    Leaflet -->|"renders"| Tile5
    Leaflet -->|"loads"| GeoEN
    Leaflet -->|"loads"| GeoES

    JS1 -->|"uses"| Markers
    JS2 -->|"uses"| Markers
    JS1 -->|"uses"| Geodesic
    JS2 -->|"uses"| Geodesic

    CSS -->|"styledBy"| Animate
    CSS -->|"styledBy"| FontAwesome

    %% Main application connections
    App --> HTML1
    App --> HTML2
    App --> CSS
    App --> Icons
    App --> JS1
    App --> JS2
    App --> Leaflet
    App --> jQuery
    App --> Lodash
    App --> Markers
    App --> Geodesic
    App --> Animate
    App --> FontAwesome
    App --> Bower

    Bower --> Leaflet
    Bower --> Markers
    Bower --> Geodesic
    Bower --> Animate
    Bower --> FontAwesome

    %% Click Events
    click HTML1 "https://github.com/todomagichere/quizzity/blob/master/index.html"
    click HTML2 "https://github.com/todomagichere/quizzity/blob/master/index_es.html"
    click CSS "https://github.com/todomagichere/quizzity/blob/master/css/quizzity.css"
    click JS1 "https://github.com/todomagichere/quizzity/blob/master/js/quizzity.js"
    click JS2 "https://github.com/todomagichere/quizzity/blob/master/js/quizzity_es.js"
    click Tile2 "https://github.com/todomagichere/quizzity/tree/master/tiles/2"
    click Tile3 "https://github.com/todomagichere/quizzity/tree/master/tiles/3"
    click Tile4 "https://github.com/todomagichere/quizzity/tree/master/tiles/4"
    click Tile5 "https://github.com/todomagichere/quizzity/tree/master/tiles/5"
    click GeoEN "https://github.com/todomagichere/quizzity/blob/master/geodata/cities-capitals_en.json"
    click GeoES "https://github.com/todomagichere/quizzity/blob/master/geodata/cities-capitals_es.json"
    click Bower "https://github.com/todomagichere/quizzity/tree/master/bower_components"
    click Animate "https://github.com/todomagichere/quizzity/blob/master/bower_components/animate.css"
    click FontAwesome "https://github.com/todomagichere/quizzity/tree/master/bower_components/font-awesome"
    click Icons "https://github.com/todomagichere/quizzity/tree/master/icon"

    %% Styles
    classDef app fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef frontend fill:#aqua,stroke:#333,stroke-width:2px;
    classDef map fill:#cfc,stroke:#333,stroke-width:2px;
    classDef tp fill:#f99,stroke:#333,stroke-width:2px;
```
