# tychoqs/safaridojo architecture

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

- Interactive diagram: https://gitdiagram.com/tychoqs/safaridojo
- Repository: https://github.com/tychoqs/safaridojo

## Overview

##### Project type and purpose
- This is a full-stack educational gaming platform (“Safari Dojo”) composed of:
- A Next.js/React client (in `client/`) that renders a library of mini-games, user account pages, profile and progress tracking
- A Node/Express back-end API (in `server/`) that exposes REST endpoints for user auth, game metadata and progress
- A MySQL database (in `database/`) managed via Docker, seeded from JSON files
- The README indicates the team’s TODOs: connect React/Next front-end to MySQL through the server, write queries, and persist data.

##### File structure
- Top level:
- `client/` – Next.js app with pages, components, public assets
- `server/` – Node/Express API, `database.js` for connection, static assets under `server/public`
- `database/` – Dockerfiles, Docker Compose, MySQL init scripts, JSON seed data
- Patterns:
- 3-tier architecture (UI / API / DB)
- Next.js → pages & API calls
- Context Providers for Auth, Profile and Goals in the client
- Static hosting of game assets (images and sounds) in both client and server

##### README for additional insights
- The tasks confirm a classic RESTful flow: React → API → MySQL

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Tier
    subgraph "Client Tier"
        BROWSER["Browser"]:::frontend
        NEXT["Next.js Front-end"]:::frontend
        subgraph "Next.js App"
            PAGES["Pages (client/src/pages/)"]:::frontend
            COMPS["Components (client/src/components/)"]:::frontend
            CTX_AUTH["AuthContext"]:::frontend
            CTX_GOAL["GoalContext"]:::frontend
            CTX_PROF["ProfileContext"]:::frontend
            STATIC_CLIENT["Static Assets (client/public/)"]:::static
        end
    end

    %% Server Tier
    subgraph "Server Tier"
        API["Express API (server/)"]:::backend
        ROUTES["Routes & Middleware (server/index.js)"]:::backend
        DB_CONN["Database Connection (server/database.js)"]:::backend
        STATIC_SERVER["Server Static Assets (server/public/sfx/)"]:::static
    end

    %% Database Tier
    subgraph "Database Tier"
        MYSQL["MySQL Database"]:::db
        DOCKER_COMPOSE["docker-compose.yml"]:::static
        DOCKERFILE["Dockerfile"]:::static
        INIT["Init Script (database/docker/mysql/init.sql)"]:::static
        JSONDATA["Seed Data (database/jsondata/)"]:::static
    end

    %% Flows
    BROWSER -->|HTTPS Requests| NEXT
    NEXT -->|Renders Pages| PAGES
    NEXT -->|Renders Components| COMPS
    NEXT -->|Uses Context| CTX_AUTH
    NEXT -->|Uses Context| CTX_GOAL
    NEXT -->|Uses Context| CTX_PROF
    NEXT -->|Serves Assets| STATIC_CLIENT

    NEXT -->|REST API Calls| API
    API -->|Handles Routes| ROUTES
    API -->|Uses DB Connector| DB_CONN
    API -->|Serves SFX| STATIC_SERVER

    DB_CONN -->|Queries| MYSQL
    DOCKER_COMPOSE -->|Configures| MYSQL
    DOCKERFILE -->|Builds Image| MYSQL
    MYSQL -->|Initialized By| INIT
    MYSQL -->|Seeded By| JSONDATA

    %% Click Events
    click NEXT "https://github.com/tychoqs/safaridojo/tree/main/client/"
    click PAGES "https://github.com/tychoqs/safaridojo/tree/main/client/src/pages/"
    click COMPS "https://github.com/tychoqs/safaridojo/tree/main/client/src/components/"
    click CTX_AUTH "https://github.com/tychoqs/safaridojo/blob/main/client/src/pages/context/AuthContext.js"
    click CTX_GOAL "https://github.com/tychoqs/safaridojo/blob/main/client/src/pages/context/GoalContext.js"
    click CTX_PROF "https://github.com/tychoqs/safaridojo/blob/main/client/src/pages/context/ProfileContext.js"
    click STATIC_CLIENT "https://github.com/tychoqs/safaridojo/tree/main/client/public/"
    click API "https://github.com/tychoqs/safaridojo/tree/main/server/"
    click ROUTES "https://github.com/tychoqs/safaridojo/blob/main/server/index.js"
    click DB_CONN "https://github.com/tychoqs/safaridojo/blob/main/server/database.js"
    click STATIC_SERVER "https://github.com/tychoqs/safaridojo/tree/main/server/public/sfx/"
    click DOCKER_COMPOSE "https://github.com/tychoqs/safaridojo/blob/main/database/docker/docker-compose.yml"
    click DOCKERFILE "https://github.com/tychoqs/safaridojo/tree/main/database/docker/Dockerfile"
    click INIT "https://github.com/tychoqs/safaridojo/blob/main/database/docker/mysql/init.sql"
    click JSONDATA "https://github.com/tychoqs/safaridojo/tree/main/database/jsondata/"

    %% Styles
    classDef frontend fill:#add8e6,stroke:#333,stroke-width:1px
    classDef backend fill:#90ee90,stroke:#333,stroke-width:1px
    classDef db fill:#ffa500,stroke:#333,stroke-width:1px
    classDef static fill:#d3d3d3,stroke:#333,stroke-width:1px
```
