# marciofelicioo/geography-quiz architecture

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

- Interactive diagram: https://gitdiagram.com/marciofelicioo/geography-quiz
- Repository: https://github.com/marciofelicioo/geography-quiz

## Overview

##### Project type and purpose
- This is a static, front-end quiz application (index.html + styles.css + script.js) delivered via GitHub Pages.
- Users see a set of flags and guess capitals; the app fetches questions/answers from a public REST API.

##### File structure
- Root files:
- index.html – single entry point (HTML template + placeholders for quiz UI)
- script.js – core quiz logic (data fetching, UI updates, score tracking)
- package.json, LICENSE, Map.mp4, Capitals.png – metadata and assets
- No backend code: all logic lives in the browser.

##### Key points from the README
- “Powered by a REST API” → there’s an external service providing country/flag/capital data.
- Built with HTML, CSS, JavaScript only.
- Deployed as a static site on GitHub Pages.

##### Main components
a. Client (Browser)
- UI Layer (HTML/CSS)
- Quiz Logic Module (script.js):
- API Service Sub-component – handles fetch requests
- Question Manager – selects and shuffles questions
- Score & State Manager – tracks user answers and score
- DOM Controller – renders questions, flags, feedback
b. External REST API
- Country Data Service (hosted elsewhere; e.g., restcountries.com)
- Provides JSON: { countryName, flagURL, capital }
c. Optional Hosting
- GitHub Pages (static file host)

##### Relationships & data flow
- Browser loads index.html + styles.css + script.js from GitHub Pages.
- Quiz Logic Module calls REST API (via fetch) to retrieve question data.
- API returns JSON → API Service → Question Manager → DOM Controller renders flag & options.
- User selects answer → Score Manager updates score → DOM Controller shows correct/incorrect → repeat.

##### Important architectural patterns & principles
- Single-Page Interaction: all logic client-side, asynchronous API calls
- Modular JavaScript: separate concerns (API wrapper, state management, rendering)
- REST interactions decoupled from UI rendering

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "User & Browser Layer"
        User((User))
        Browser["Browser"]:::module
        User -->|"interacts with"|Browser
        subgraph "UI Layer"
            HTML["index.html"]:::module
            CSS["styles.css"]:::module
        end
        Browser -->|"renders UI"|HTML
        Browser -->|"applies styles"|CSS
    end

    subgraph "Client-Side Logic Layer"
        Quiz["script.js"]:::module
        APIService["API Service"]:::module
        QuestionManager["Question Manager"]:::module
        ScoreManager["Score & State Manager"]:::module
        DOMController["DOM Controller"]:::module

        Browser -->|"loads script"|Quiz
        Quiz -->|"initializes modules"|APIService
        APIService -->|"provides data to"|QuestionManager
        QuestionManager -->|"sends question to"|DOMController
        DOMController -->|"captures answer to"|ScoreManager
        ScoreManager -->|"updates UI via"|DOMController
    end

    subgraph "External Services Layer"
        REST["External REST API"]:::external
        Host["GitHub Pages Host"]:::external

        Browser -->|"load assets from"|Host
        APIService -->|"fetch country data"|REST
    end

    subgraph "Project Metadata & Assets"
        License["LICENSE"]:::data
        Readme["README.md"]:::data
        Video["Map.mp4"]:::data
    end

    click HTML "https://github.com/marciofelicioo/geography-quiz/blob/main/index.html"
    click CSS "https://github.com/marciofelicioo/geography-quiz/blob/main/styles.css"
    click Quiz "https://github.com/marciofelicioo/geography-quiz/blob/main/script.js"
    click Host "https://github.com/marciofelicioo/geography-quiz/blob/main/package.json"
    click License "https://github.com/marciofelicioo/geography-quiz/tree/main/LICENSE"
    click Readme "https://github.com/marciofelicioo/geography-quiz/blob/main/README.md"
    click Video "https://github.com/marciofelicioo/geography-quiz/blob/main/Map.mp4"

    classDef module fill:#D6EAF8,stroke:#2E86C1;
    classDef external fill:#ABEBC6,stroke:#28B463;
    classDef data fill:#F9E79F,stroke:#B7950B;
```
