# aoe4world/explorer architecture

> Architecture diagram of the GitHub repository aoe4world/explorer, 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/aoe4world/explorer
- Repository: https://github.com/aoe4world/explorer

## Overview

##### Project Type and Purpose
- The project is a frontend application for visualizing units, their stats, abilities, upgrades, and technologies for Age Of Empires 4. The README makes it clear that this is a specialized visualization and exploration tool.
- The stack includes TypeScript, SolidJS for reactive UI components, Tailwind CSS for styling, and Vite for the build and development workflow. It also uses a submodule for data (which likely contains game reference and patch data).

##### File Structure
- Top-level files include configuration files (package.json, vite.config.ts, tailwind.config.js, tsconfig.json, etc.), indicating a modern web development setup.
- The assets directory holds images and resources (such as flags, backdrops, and resource files) used in the UI.
- The src directory, which is the heart of the application, is further subdivided into components (individual UI pieces), routes (page-level components corresponding to different views like buildings, civs, patches, units, etc.), and data / query folders.
- The src/data folder includes game-specific data such as civ information and patch data record paths that are sourced as TypeScript modules.
- The src/query folder suggests a layer for fetching or transforming these datasets.
- The presence of subdirectories like components/quiz indicates specific modules (i.e., the Quiz feature) that are specialized parts of the application.
- The file structure hints at a clear separation between UI elements (components and routes), data entities (data and query), and configuration files/build scripts.

a. Main Components:
- Browser Client: The end user interacts with the application through a web browser.
- Vite Development Server / Build Pipeline: Manages hot-reloading and builds the application.
- SolidJS Framework Layer: The core reactive framework managing state and rendering.
- UI Components: Located in the src/components directory, these represent individual, reusable UI pieces (e.g., BuildingCard, CivFlag, TechnologyCard, etc.).
- Routing Layer: Defined in the src/routes directory, it determines different application views/pages such as Home, Buildings, Civs, Units, and Quiz.
- Data Layer: Involves directories like src/data (for static game data, patches, civData, etc.) and src/query (for data fetching/manipulation functions).
- Assets: Media content including images, flags, backdrops stored in the assets/ folder.
- External Dependencies: Tailwind CSS for styling, Tailwind configuration file, and additional system configuration files.

b. Relationships and Interactions:
- A user in the browser interacts with the UI, which is rendered by SolidJS components.
- The UI components communicate with the routing system (in src/routes) to manage navigation between pages (e.g., viewing detail for a building or unit).
- Many components will depend on data provided by the src/data and src/query modules to display up-to-date statistics, patch histories, and other details.
- The Vite build server integrates these components, assets, and configuration files to create the final application bundle.
- Data flows downward from static game data (located in data and submodules) to query functions that transform and provide data to UI components.

c. Architectural Patterns and Design Principles:
- Component-Based Architecture: The project is clearly divided into modular UI components.
- MV* Patterns: There is a separation between the view layer (UI components) and the data layers (src/data and src/query), echoing principles similar to MVC or MVVM.
- Routing as a means for organizing views: Each route in src/routes maps directly to a part of the UI.
- The configuration and asset management also shows separation of concerns, keeping visual assets, configuration, and code separate.

d. Specific Technologies:
- SolidJS for reactive UI
- TypeScript for type safety and clarity
- Tailwind CSS for rapid styling and theming
- Vite for efficient development workflow and bundling
- Git submodules which are used to manage external data repositories.

- Component is clearly labeled (e.g., “SolidJS UI Components”, “Vite Build Server”, “Data/Query Layer”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Application Layer
    BC("Browser Client"):::client
    Vite("Vite Development Server & Build Pipeline"):::build
    Solid("SolidJS Framework Layer"):::framework
    UI("UI Components"):::ui
    Routes("Routing Layer"):::routing
    Quiz("Quiz Module"):::quiz

    %% Data and Assets Layer
    Data("Data Layer"):::data
    Query("Data Query Functions"):::query
    Assets("Assets"):::asset

    %% Relationships
    BC -->|"requests"| Vite
    Vite -->|"bundles"| Solid
    Solid -->|"renders"| UI
    Solid -->|"navigates"| Routes
    Routes -->|"loads"| UI
    UI -->|"includes"| Quiz

    Data -->|"provides"| Query
    Query -->|"suppliesData"| UI
    Assets -->|"resources"| UI

    %% Click Events
    click BC "https://github.com/aoe4world/explorer/blob/main/index.html"
    
    click Vite "https://github.com/aoe4world/explorer/blob/main/vite.config.ts"
    click Vite "https://github.com/aoe4world/explorer/blob/main/package.json"
    click Vite "https://github.com/aoe4world/explorer/blob/main/postcss.config.js"
    click Vite "https://github.com/aoe4world/explorer/blob/main/tsconfig.json"
    
    click Solid "https://github.com/aoe4world/explorer/blob/main/src/index.tsx"
    click Solid "https://github.com/aoe4world/explorer/blob/main/src/App.tsx"
    click Solid "https://github.com/aoe4world/explorer/blob/main/src/global.tsx"
    
    click UI "https://github.com/aoe4world/explorer/tree/main/src/components"
    click Routes "https://github.com/aoe4world/explorer/tree/main/src/routes"
    click Data "https://github.com/aoe4world/explorer/tree/main/src/data"
    click Query "https://github.com/aoe4world/explorer/tree/main/src/query"
    click Assets "https://github.com/aoe4world/explorer/tree/main/assets"
    
    click Quiz "https://github.com/aoe4world/explorer/tree/main/src/components/quiz"
    click Quiz "https://github.com/aoe4world/explorer/tree/main/src/routes/quiz"
    
    %% Styles
    classDef client fill:#AEDFF7,stroke:#000,stroke-width:1px;
    classDef build fill:#F7D6AE,stroke:#000,stroke-width:1px;
    classDef framework fill:#E6F7AE,stroke:#000,stroke-width:1px;
    classDef ui fill:#D6AEF7,stroke:#000,stroke-width:1px;
    classDef routing fill:#F7AEF7,stroke:#000,stroke-width:1px;
    classDef quiz fill:#E0B0FF,stroke:#000,stroke-width:1px;
    classDef data fill:#C7E0F7,stroke:#000,stroke-width:1px;
    classDef query fill:#F0E68C,stroke:#000,stroke-width:1px;
    classDef asset fill:#D1F7C4,stroke:#000,stroke-width:1px;
```
