# jalenng/dont-set-ca-on-fire architecture

> Architecture diagram of the GitHub repository jalenng/dont-set-ca-on-fire, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jalenng/dont-set-ca-on-fire
- Repository: https://github.com/jalenng/dont-set-ca-on-fire

## Overview

##### Project Overview
- This is a game project created during SCEhacks 2021 that combines an interactive Unity-based trivia game with a Flask backend, which in turn communicates with an Azure SQL database. Its purpose is to educate players about the wildfire crisis through gameplay.
- The project includes a Unity game client (located in the DSCoF directory) with assets like animations, images, fonts, and game scripts written in C#, and a Flask application (in the flaskapp directory) that provides API endpoints for the game, handling database interactions.

##### Main Components
a. Unity Game Client:
- Managed under the DSCoF directory. It hosts assets (Animations, Images, Scenes, Scripts, etc.) and contains key C# scripts (such as ButtonController, FireController, GuyController, etc.) that control the game’s logic.
- Serves as the front-end interface, handling game display, player input, and in-game interactions.
b. Flask Backend Server:
- Found in the flaskapp directory, with files like __init__.py, routes.py, and sql_connection.py.
- Acts as the API layer that receives GET and POST requests from the Unity game, processes them (e.g., querying and updating data), and relays responses.
c. Azure SQL Database:
- Not directly shown in the file tree but referenced in the README. It is where game analytic data (such as player statistics and answers) are stored.
d. Art Assets/Sprite Tools:
- Additional directories like aseprite indicate the use of external tools (Aseprite for sprite creation) though they’re not part of runtime architecture. You may note these as part of the asset creation workflow.

##### Relationships & Data Flow
- The Unity client sends HTTP POST and GET requests to the Flask server. This is a key integration point where game events (such as submitting answers or requesting results) are transmitted.
- The Flask server then connects to the Azure SQL database by executing SQL queries via configured Python libraries, retrieves or updates the necessary data, and sends the response back to Unity.
- Internally within Unity, various game systems (controllers and managers such as QuestionManager, ResultManager, and StatsManager) process the data and update the game state.
- Overall data flow: User interaction in Unity → Unity triggers C# scripts → HTTP request to Flask server → Flask queries/updates Azure SQL → Flask returns data to Unity → Unity displays data and adjusts gameplay.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer - Unity Game Client
    subgraph "Frontend (Unity Game Client)"
        U["Unity Game Client"]:::unity
        subgraph "Game Components"
            A["Assets (Animations, Images, Scenes)"]:::asset
            L["Game Logic (C# Scripts: ButtonController, FireController, GuyController, QuestionManager, ResultManager, StatsManager)"]:::logic
        end
    end

    %% API Layer - Flask Server
    subgraph "API Layer (Flask Server)"
        F["Flask API Server\n(__init__.py, routes.py, sql_connection.py)"]:::flask
    end

    %% Data Layer - Azure SQL Database
    subgraph "Data Layer"
        D["Azure SQL Database\n(Game Analytics and Player Data)"]:::database
    end

    %% External Tools
    E["External Art Tools (Aseprite Files)"]:::external

    %% Connections
    U -->|"SendsHTTPGET/POST"| F
    L -->|"TriggersAPICalls"| F
    F -->|"ExecutesSQLQueries"| D
    A -->|"Designedwith"| E

    %% Click Events
    click U "https://github.com/jalenng/dont-set-ca-on-fire/tree/main/DSCoF"
    click A "https://github.com/jalenng/dont-set-ca-on-fire/tree/main/DSCoF/Assets"
    click L "https://github.com/jalenng/dont-set-ca-on-fire/tree/main/DSCoF/Assets/Scripts"
    click F "https://github.com/jalenng/dont-set-ca-on-fire/tree/main/flaskapp"
    click E "https://github.com/jalenng/dont-set-ca-on-fire/tree/main/aseprite"

    %% Styles
    classDef unity fill:#b3cde0,stroke:#03396c,stroke-width:2px;
    classDef asset fill:#ccebc5,stroke:#2b9348,stroke-width:2px;
    classDef logic fill:#decbe4,stroke:#7b3294,stroke-width:2px;
    classDef flask fill:#fbb4ae,stroke:#e31a1c,stroke-width:2px;
    classDef database fill:#ffffcc,stroke:#b8b800,stroke-width:2px;
    classDef external fill:#fed9a6,stroke:#e6550d,stroke-width:2px;
```
