# csc105-2024/g10-lootbox architecture

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

- Interactive diagram: https://gitdiagram.com/csc105-2024/g10-lootbox
- Repository: https://github.com/csc105-2024/g10-lootbox

## Overview

This is a free loot-box web app: users sign up, receive regenerating keys, open meme or superhero boxes, collect items, and manage coins, inventory, and profile images. The React pages call API helpers, which communicate with a Hono backend; controllers coordinate user, key, item, and summon operations backed by Prisma. The graph includes README-documented capabilities whose implementation was not sampled, but omits uncertain links where source excerpts do not establish the call path.

Main entry points: [`frontend/src/App.jsx`](https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/App.jsx) (Page routing), [`backend/src/index.ts`](https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/index.ts) (Hono server), [`backend/src/models/user.model.ts`](https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/models/user.model.ts) (User and inventory), [`frontend/src/api/user.ts`](https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/api/user.ts) (User API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React client"]
  node_app["Page routing<br/>[App.jsx]"]
  node_auth_ui["Sign-in and signup"]
  node_home["Game home<br/>[Main.jsx]"]
  node_box_ui["Box selection<br/>[SuperHeroBox.jsx]"]
  node_summon_ui["Random draws<br/>[HeroRandom.jsx]"]
  node_item_views["Item views<br/>[heroLook.jsx]"]
  node_shop_ui["Buy and sell<br/>[Buying.jsx]"]
  node_profile_ui["User profile<br/>[profile.jsx]"]
  node_api_user["User API<br/>[user.ts]"]
  node_api_shop["Shop API<br/>[shop.ts]"]
  node_api_summon["Summon API<br/>[summon.ts]"]
  node_api_inventory["Inventory API<br/>[inventory.ts]"]
  node_http_client["Axios client<br/>[axiosInstance.ts]"]
end

subgraph group_http["HTTP API"]
  node_server["Hono server<br/>[index.ts]"]
  node_user_routes["User routes<br/>[user.routes.ts]"]
  node_shop_routes["Shop routes<br/>[shop.routes.ts]"]
  node_inventory_routes["Inventory routes"]
  node_summon_routes["Summon routes<br/>[summon.routes.ts]"]
end

subgraph group_domain["Game domain"]
  node_user_controller["User operations<br/>[user.controller.ts]"]
  node_shop_controller["Shop operations<br/>[shop.controller.ts]"]
  node_item_controller["Item queries<br/>[item.controller.ts]"]
  node_summon_controller["Summon operations"]
  node_user_model["User and inventory<br/>[user.model.ts]"]
  node_key_model["Keys and cooldowns<br/>[key.model.ts]"]
  node_item_model["Item operations<br/>[item.model.ts]"]
  node_summon_model["Draw logic<br/>[summon.model.ts]"]
  node_file_handler["Image file handling<br/>[fileHandler.ts]"]
end

subgraph group_persistence["Persistence"]
  node_database[("Prisma database<br/>[schema.prisma]")]
end

node_player(("Player"))

node_player -->|"uses"| node_app
node_app -->|"routes to"| node_auth_ui
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_box_ui
node_app -->|"routes to"| node_summon_ui
node_app -->|"routes to"| node_item_views
node_app -->|"routes to"| node_shop_ui
node_app -->|"routes to"| node_profile_ui
node_auth_ui -->|"calls"| node_api_user
node_home -->|"fetches profile"| node_api_user
node_shop_ui -->|"calls"| node_api_shop
node_shop_ui -->|"fetches user"| node_api_user
node_summon_ui -->|"requests draw"| node_api_summon
node_profile_ui -->|"calls"| node_api_user
node_api_user -->|"sends requests"| node_http_client
node_api_shop -->|"sends requests"| node_http_client
node_api_summon -->|"sends requests"| node_http_client
node_api_inventory -->|"sends requests"| node_http_client
node_http_client -->|"HTTP requests"| node_server
node_server -->|"mounts routes"| node_user_routes
node_server -->|"mounts routes"| node_shop_routes
node_server -->|"mounts routes"| node_inventory_routes
node_server -->|"mounts routes"| node_summon_routes
node_user_routes -->|"dispatches"| node_user_controller
node_shop_routes -->|"dispatches"| node_shop_controller
node_inventory_routes -->|"dispatches"| node_user_controller
node_inventory_routes -->|"dispatches"| node_item_controller
node_summon_routes -->|"dispatches"| node_summon_controller
node_user_controller -->|"calls"| node_user_model
node_user_controller -->|"calls"| node_key_model
node_shop_controller -->|"calls"| node_user_model
node_shop_controller -->|"calls"| node_key_model
node_shop_controller -->|"calls"| node_item_model
node_item_controller -->|"calls"| node_item_model
node_summon_controller -->|"calls"| node_summon_model
node_summon_model -->|"uses"| node_user_model
node_summon_model -->|"uses"| node_key_model
node_summon_model -->|"uses"| node_item_model
node_user_model -->|"saves images"| node_file_handler
node_user_model -->|"reads and writes"| node_database
node_key_model -->|"reads and writes"| node_database
node_item_model -->|"reads and writes"| node_database

click node_app "https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/App.jsx"
click node_auth_ui "https://github.com/csc105-2024/g10-lootbox/tree/master/frontend/src/pages"
click node_home "https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/pages/Main.jsx"
click node_box_ui "https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/pages/SuperHeroBox.jsx"
click node_summon_ui "https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/pages/HeroRandom.jsx"
click node_item_views "https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/pages/heroLook.jsx"
click node_shop_ui "https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/pages/Buying.jsx"
click node_profile_ui "https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/pages/profile.jsx"
click node_api_user "https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/api/user.ts"
click node_api_shop "https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/api/shop.ts"
click node_api_summon "https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/api/summon.ts"
click node_api_inventory "https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/api/inventory.ts"
click node_http_client "https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/util/axiosInstance.ts"
click node_server "https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/index.ts"
click node_user_routes "https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/routes/user.routes.ts"
click node_shop_routes "https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/routes/shop.routes.ts"
click node_inventory_routes "https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/routes/inventory.routes.ts"
click node_summon_routes "https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/routes/summon.routes.ts"
click node_user_controller "https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/controllers/user.controller.ts"
click node_shop_controller "https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/controllers/shop.controller.ts"
click node_item_controller "https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/controllers/item.controller.ts"
click node_summon_controller "https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/controllers/summon.controller.ts"
click node_user_model "https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/models/user.model.ts"
click node_key_model "https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/models/key.model.ts"
click node_item_model "https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/models/item.model.ts"
click node_summon_model "https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/models/summon.model.ts"
click node_file_handler "https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/utils/fileHandler.ts"
click node_database "https://github.com/csc105-2024/g10-lootbox/blob/master/backend/prisma/schema.prisma"

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_app,node_auth_ui,node_home,node_box_ui,node_summon_ui,node_item_views,node_shop_ui,node_profile_ui,node_api_user,node_api_shop,node_api_summon,node_api_inventory,node_http_client toneBlue
class node_server,node_user_routes,node_shop_routes,node_inventory_routes,node_summon_routes toneAmber
class node_user_controller,node_shop_controller,node_item_controller,node_summon_controller,node_user_model,node_key_model,node_item_model,node_summon_model,node_file_handler toneMint
class node_database toneRose
class node_player toneIndigo
```

## Components

### React client

- [Page routing](https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Sign-in and signup](https://github.com/csc105-2024/g10-lootbox/tree/master/frontend/src/pages): `frontend/src/pages`
- [Game home](https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/pages/Main.jsx): `frontend/src/pages/Main.jsx`
- [Box selection](https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/pages/SuperHeroBox.jsx): `frontend/src/pages/SuperHeroBox.jsx`
- [Random draws](https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/pages/HeroRandom.jsx): `frontend/src/pages/HeroRandom.jsx`
- [Item views](https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/pages/heroLook.jsx): `frontend/src/pages/heroLook.jsx`
- [Buy and sell](https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/pages/Buying.jsx): `frontend/src/pages/Buying.jsx`
- [User profile](https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/pages/profile.jsx): `frontend/src/pages/profile.jsx`
- [User API](https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/api/user.ts): `frontend/src/api/user.ts`
- [Shop API](https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/api/shop.ts): `frontend/src/api/shop.ts`
- [Summon API](https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/api/summon.ts): `frontend/src/api/summon.ts`
- [Inventory API](https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/api/inventory.ts): `frontend/src/api/inventory.ts`
- [Axios client](https://github.com/csc105-2024/g10-lootbox/blob/master/frontend/src/util/axiosInstance.ts): `frontend/src/util/axiosInstance.ts`

### HTTP API

- [Hono server](https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/index.ts): `backend/src/index.ts`
- [User routes](https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/routes/user.routes.ts): `backend/src/routes/user.routes.ts`
- [Shop routes](https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/routes/shop.routes.ts): `backend/src/routes/shop.routes.ts`
- [Inventory routes](https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/routes/inventory.routes.ts): `backend/src/routes/inventory.routes.ts`
- [Summon routes](https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/routes/summon.routes.ts): `backend/src/routes/summon.routes.ts`

### Game domain

- [User operations](https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/controllers/user.controller.ts): `backend/src/controllers/user.controller.ts`
- [Shop operations](https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/controllers/shop.controller.ts): `backend/src/controllers/shop.controller.ts`
- [Item queries](https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/controllers/item.controller.ts): `backend/src/controllers/item.controller.ts`
- [Summon operations](https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/controllers/summon.controller.ts): `backend/src/controllers/summon.controller.ts`
- [User and inventory](https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/models/user.model.ts): `backend/src/models/user.model.ts`
- [Keys and cooldowns](https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/models/key.model.ts): `backend/src/models/key.model.ts`
- [Item operations](https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/models/item.model.ts): `backend/src/models/item.model.ts`
- [Draw logic](https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/models/summon.model.ts): `backend/src/models/summon.model.ts`
- [Image file handling](https://github.com/csc105-2024/g10-lootbox/blob/master/backend/src/utils/fileHandler.ts): `backend/src/utils/fileHandler.ts`

### Persistence

- [Prisma database](https://github.com/csc105-2024/g10-lootbox/blob/master/backend/prisma/schema.prisma): `backend/prisma/schema.prisma`

### Other components

- **Player**

## Connections

- Player → Page routing: uses (evidence: `README.md`)
- Page routing → Sign-in and signup: routes to (evidence: `frontend/src/App.jsx`)
- Page routing → Game home: routes to (evidence: `frontend/src/App.jsx`)
- Page routing → Box selection: routes to (evidence: `frontend/src/App.jsx`)
- Page routing → Random draws: routes to (evidence: `frontend/src/App.jsx`)
- Page routing → Item views: routes to (evidence: `frontend/src/App.jsx`)
- Page routing → Buy and sell: routes to (evidence: `frontend/src/App.jsx`)
- Page routing → User profile: routes to (evidence: `frontend/src/App.jsx`)
- Sign-in and signup → User API: calls (evidence: `frontend/src/pages/SignUp.jsx`)
- Game home → User API: fetches profile (evidence: `frontend/src/pages/Main.jsx`)
- Buy and sell → Shop API: calls (evidence: `frontend/src/pages/Buying.jsx`)
- Buy and sell → User API: fetches user (evidence: `frontend/src/pages/Buying.jsx`)
- Random draws → Summon API: requests draw (evidence: `frontend/src/pages/HeroRandom.jsx`)
- User profile → User API: calls (evidence: `frontend/src/pages/profile.jsx`)
- User API → Axios client: sends requests (evidence: `frontend/src/api/user.ts`)
- Shop API → Axios client: sends requests (evidence: `frontend/src/api/shop.ts`)
- Summon API → Axios client: sends requests (evidence: `frontend/src/api/summon.ts`)
- Inventory API → Axios client: sends requests (evidence: `frontend/src/api/inventory.ts`)
- Axios client → Hono server: HTTP requests (evidence: `README.md`)
- Hono server → User routes: mounts routes (evidence: `backend/src/index.ts`)
- Hono server → Shop routes: mounts routes
- Hono server → Inventory routes: mounts routes
- Hono server → Summon routes: mounts routes
- User routes → User operations: dispatches (evidence: `backend/src/routes/user.routes.ts`)
- Shop routes → Shop operations: dispatches (evidence: `backend/src/routes/shop.routes.ts`)
- Inventory routes → User operations: dispatches (evidence: `backend/src/routes/inventory.routes.ts`)
- Inventory routes → Item queries: dispatches (evidence: `backend/src/routes/inventory.routes.ts`)
- Summon routes → Summon operations: dispatches (evidence: `backend/src/routes/summon.routes.ts`)
- User operations → User and inventory: calls (evidence: `backend/src/controllers/user.controller.ts`)
- User operations → Keys and cooldowns: calls (evidence: `backend/src/controllers/user.controller.ts`)
- Shop operations → User and inventory: calls (evidence: `backend/src/controllers/shop.controller.ts`)
- Shop operations → Keys and cooldowns: calls (evidence: `backend/src/controllers/shop.controller.ts`)
- Shop operations → Item operations: calls (evidence: `backend/src/controllers/shop.controller.ts`)
- Item queries → Item operations: calls (evidence: `backend/src/controllers/item.controller.ts`)
- Summon operations → Draw logic: calls (evidence: `backend/src/controllers/summon.controller.ts`)
- Draw logic → User and inventory: uses (evidence: `backend/src/models/summon.model.ts`)
- Draw logic → Keys and cooldowns: uses (evidence: `backend/src/models/summon.model.ts`)
- Draw logic → Item operations: uses (evidence: `backend/src/models/summon.model.ts`)
- User and inventory → Image file handling: saves images (evidence: `backend/src/models/user.model.ts`)
- User and inventory → Prisma database: reads and writes (evidence: `backend/src/models/user.model.ts`)
- Keys and cooldowns → Prisma database: reads and writes (evidence: `backend/src/models/key.model.ts`)
- Item operations → Prisma database: reads and writes (evidence: `backend/src/models/item.model.ts`)
