# mo7amed-3zmy/zonefullstack architecture

> Architecture diagram of the GitHub repository mo7amed-3zmy/zonefullstack, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mo7amed-3zmy/zonefullstack
- Repository: https://github.com/mo7amed-3zmy/zonefullstack

## Overview

Zone Zero is a Discord community bot with a web dashboard and a separate media worker. The primary workflow is member activity handled by the bot, translated into XP/points and persisted user state, then surfaced through leaderboards, profiles, and other dashboard pages. Administrative controls, achievements, tasks, games, and media upload/gallery are distinct capabilities. The README is empty; links are limited to relationships supported by the sampled excerpts or SOURCE INDEX, so frontend-to-backend and bot-event flows are not inferred.

Main entry points: [`backend/src/index.js`](https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/index.js) (Bot runtime), [`backend/src/models/CombinedUser.js`](https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/models/CombinedUser.js) (Combined user state), [`backend/src/services/xpService.js`](https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/services/xpService.js) (XP tracking), [`media-worker/src/routes`](https://github.com/mo7amed-3zmy/zonefullstack/tree/main/media-worker/src/routes) (Media handlers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bot["Discord bot"]
  node_bot_entry["Bot runtime<br/>[index.js]"]
  node_commands["Bot commands"]
  node_events["Discord events"]
  node_games["Community games"]
  node_config["Bot configuration<br/>[config.js]"]
end

subgraph group_domain["Community systems"]
  node_xp["XP tracking<br/>[xpService.js]"]
  node_points["Points economy<br/>[pointsService.js]"]
  node_achievements["Achievements"]
  node_boosts["XP boosts<br/>[boostService.js]"]
  node_loans["Loans<br/>[loanService.js]"]
  node_tasks["Task notifications"]
  node_admin["Admin operations<br/>[adminService.js]"]
end

subgraph group_web["Web dashboard"]
  node_api["REST API<br/>[index.js]"]
  node_api_routes["API routes"]
  node_frontend["Dashboard app<br/>[App.tsx]"]
  node_dashboard_pages["Dashboard pages"]
  node_photo_page["Photo gallery UI<br/>[PhotoPage.tsx]"]
end

subgraph group_media["Media service"]
  node_media_entry["Media worker<br/>[index.ts]"]
  node_media_routes["Media handlers"]
  node_media_auth["Media authorization<br/>[auth.ts]"]
  node_media_moderation["Upload moderation<br/>[moderation.ts]"]
  node_media_storage["Media storage<br/>[types.ts]"]
end

subgraph group_data["Persistence"]
  node_user_model[("Combined user state<br/>[CombinedUser.js]")]
  node_leaderboard_model[("Leaderboard records<br/>[TopUser.js]")]
  node_pg["PostgreSQL client<br/>[pgClient.js]"]
end

node_member(("Discord members"))

node_bot_entry -->|"starts API"| node_api
node_bot_entry -->|"initializes boosts"| node_boosts
node_bot_entry -->|"initializes cache"| node_xp
node_bot_entry -->|"syncs definitions"| node_achievements
node_api -->|"registers routes"| node_api_routes
node_frontend -->|"routes to"| node_dashboard_pages
node_media_entry -->|"verifies access"| node_media_auth
node_media_entry -->|"dispatches requests"| node_media_routes
node_media_routes -->|"moderates uploads"| node_media_moderation
node_media_routes -->|"uses bindings"| node_media_storage
node_xp -->|"updates user state"| node_user_model
node_xp -->|"updates rankings"| node_leaderboard_model
node_points -->|"reads balance"| node_user_model
node_admin -->|"updates users"| node_user_model
node_admin -->|"updates rankings"| node_leaderboard_model
node_user_model -->|"queries database"| node_pg
node_leaderboard_model -->|"queries database"| node_pg

click node_bot_entry "https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/index.js"
click node_commands "https://github.com/mo7amed-3zmy/zonefullstack/tree/main/backend/src/commands"
click node_events "https://github.com/mo7amed-3zmy/zonefullstack/tree/main/backend/src/events"
click node_games "https://github.com/mo7amed-3zmy/zonefullstack/tree/main/backend/src/games"
click node_xp "https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/services/xpService.js"
click node_points "https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/services/pointsService.js"
click node_achievements "https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/services/achievementService.js"
click node_boosts "https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/services/boostService.js"
click node_loans "https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/services/loanService.js"
click node_tasks "https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/services/taskNotificationService.js"
click node_admin "https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/services/adminService.js"
click node_api "https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/api/index.js"
click node_api_routes "https://github.com/mo7amed-3zmy/zonefullstack/tree/main/backend/src/api/routes"
click node_frontend "https://github.com/mo7amed-3zmy/zonefullstack/blob/main/frontend/src/App.tsx"
click node_dashboard_pages "https://github.com/mo7amed-3zmy/zonefullstack/tree/main/frontend/src/pages"
click node_photo_page "https://github.com/mo7amed-3zmy/zonefullstack/blob/main/frontend/src/pages/PhotoPage.tsx"
click node_media_entry "https://github.com/mo7amed-3zmy/zonefullstack/blob/main/media-worker/src/index.ts"
click node_media_routes "https://github.com/mo7amed-3zmy/zonefullstack/tree/main/media-worker/src/routes"
click node_media_auth "https://github.com/mo7amed-3zmy/zonefullstack/blob/main/media-worker/src/utils/auth.ts"
click node_media_moderation "https://github.com/mo7amed-3zmy/zonefullstack/blob/main/media-worker/src/utils/moderation.ts"
click node_media_storage "https://github.com/mo7amed-3zmy/zonefullstack/blob/main/media-worker/src/types.ts"
click node_user_model "https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/models/CombinedUser.js"
click node_leaderboard_model "https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/models/TopUser.js"
click node_pg "https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/utils/pgClient.js"
click node_config "https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/config.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_bot_entry,node_commands,node_events,node_games,node_config toneBlue
class node_xp,node_points,node_achievements,node_boosts,node_loans,node_tasks,node_admin toneAmber
class node_api,node_api_routes,node_frontend,node_dashboard_pages,node_photo_page toneMint
class node_media_entry,node_media_routes,node_media_auth,node_media_moderation,node_media_storage toneRose
class node_user_model,node_leaderboard_model,node_pg,node_member toneIndigo
```

## Components

### Discord bot

- [Bot runtime](https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/index.js): `backend/src/index.js`
- [Bot commands](https://github.com/mo7amed-3zmy/zonefullstack/tree/main/backend/src/commands): `backend/src/commands`
- [Discord events](https://github.com/mo7amed-3zmy/zonefullstack/tree/main/backend/src/events): `backend/src/events`
- [Community games](https://github.com/mo7amed-3zmy/zonefullstack/tree/main/backend/src/games): `backend/src/games`
- [Bot configuration](https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/config.js): `backend/src/config.js`

### Community systems

- [XP tracking](https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/services/xpService.js): `backend/src/services/xpService.js`
- [Points economy](https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/services/pointsService.js): `backend/src/services/pointsService.js`
- [Achievements](https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/services/achievementService.js): `backend/src/services/achievementService.js`
- [XP boosts](https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/services/boostService.js): `backend/src/services/boostService.js`
- [Loans](https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/services/loanService.js): `backend/src/services/loanService.js`
- [Task notifications](https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/services/taskNotificationService.js): `backend/src/services/taskNotificationService.js`
- [Admin operations](https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/services/adminService.js): `backend/src/services/adminService.js`

### Web dashboard

- [REST API](https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/api/index.js): `backend/src/api/index.js`
- [API routes](https://github.com/mo7amed-3zmy/zonefullstack/tree/main/backend/src/api/routes): `backend/src/api/routes`
- [Dashboard app](https://github.com/mo7amed-3zmy/zonefullstack/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Dashboard pages](https://github.com/mo7amed-3zmy/zonefullstack/tree/main/frontend/src/pages): `frontend/src/pages`
- [Photo gallery UI](https://github.com/mo7amed-3zmy/zonefullstack/blob/main/frontend/src/pages/PhotoPage.tsx): `frontend/src/pages/PhotoPage.tsx`

### Media service

- [Media worker](https://github.com/mo7amed-3zmy/zonefullstack/blob/main/media-worker/src/index.ts): `media-worker/src/index.ts`
- [Media handlers](https://github.com/mo7amed-3zmy/zonefullstack/tree/main/media-worker/src/routes): `media-worker/src/routes`
- [Media authorization](https://github.com/mo7amed-3zmy/zonefullstack/blob/main/media-worker/src/utils/auth.ts): `media-worker/src/utils/auth.ts`
- [Upload moderation](https://github.com/mo7amed-3zmy/zonefullstack/blob/main/media-worker/src/utils/moderation.ts): `media-worker/src/utils/moderation.ts`
- [Media storage](https://github.com/mo7amed-3zmy/zonefullstack/blob/main/media-worker/src/types.ts): `media-worker/src/types.ts`

### Persistence

- [Combined user state](https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/models/CombinedUser.js): `backend/src/models/CombinedUser.js`
- [Leaderboard records](https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/models/TopUser.js): `backend/src/models/TopUser.js`
- [PostgreSQL client](https://github.com/mo7amed-3zmy/zonefullstack/blob/main/backend/src/utils/pgClient.js): `backend/src/utils/pgClient.js`

### Other components

- **Discord members**

## Connections

- Bot runtime → REST API: starts API (evidence: `backend/src/index.js`)
- Bot runtime → XP boosts: initializes boosts (evidence: `backend/src/index.js`)
- Bot runtime → XP tracking: initializes cache (evidence: `backend/src/index.js`)
- Bot runtime → Achievements: syncs definitions (evidence: `backend/src/index.js`)
- REST API → API routes: registers routes (evidence: `backend/src/api/index.js`)
- Dashboard app → Dashboard pages: routes to (evidence: `frontend/src/App.tsx`)
- Media worker → Media authorization: verifies access (evidence: `media-worker/src/index.ts`)
- Media worker → Media handlers: dispatches requests (evidence: `media-worker/src/index.ts`)
- Media handlers → Upload moderation: moderates uploads (evidence: `media-worker/src/routes/upload.ts`)
- Media handlers → Media storage: uses bindings (evidence: `media-worker/src/routes/media.ts`)
- XP tracking → Combined user state: updates user state (evidence: `backend/src/services/xpService.js`)
- XP tracking → Leaderboard records: updates rankings (evidence: `backend/src/services/xpService.js`)
- Points economy → Combined user state: reads balance (evidence: `backend/src/services/pointsService.js`)
- Admin operations → Combined user state: updates users (evidence: `backend/src/services/adminService.js`)
- Admin operations → Leaderboard records: updates rankings (evidence: `backend/src/services/adminService.js`)
- Combined user state → PostgreSQL client: queries database (evidence: `backend/src/models/CombinedUser.js`)
- Leaderboard records → PostgreSQL client: queries database (evidence: `backend/src/models/TopUser.js`)
