# antusantury/hoodiediamond architecture

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

- Interactive diagram: https://gitdiagram.com/antusantury/hoodiediamond
- Repository: https://github.com/antusantury/hoodiediamond

## Overview

Hoodie Diamond is a backend for chance-based gaming. A player enters through the Express API or a Socket.io connection; game requests are authenticated and rate-limited, then handled by chance-game logic that uses RNG and probability components. Other product branches cover inventory, player trading, payments, user accounts, and mobile support. MongoDB-backed models hold player and game state, while Redis supports caching and socket scaling. Some route and service details are represented from the README and SOURCE INDEX; unsampled implementation links are omitted where their ownership is unclear.

Main entry points: [`src/server.ts`](https://github.com/antusantury/hoodiediamond/blob/main/src/server.ts) (HTTP Server), [`src/services/ChanceService.ts`](https://github.com/antusantury/hoodiediamond/blob/main/src/services/ChanceService.ts) (Chance Service), [`src/services/SocketService.ts`](https://github.com/antusantury/hoodiediamond/blob/main/src/services/SocketService.ts) (Socket Service), [`src/services/MarketplaceService.ts`](https://github.com/antusantury/hoodiediamond/blob/main/src/services/MarketplaceService.ts) (Marketplace Service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime API"]
  node_server["HTTP Server<br/>[server.ts]"]
  node_game_routes["Game Routes<br/>[games.ts]"]
  node_inventory_routes["Inventory Routes<br/>[inventory.ts]"]
  node_market_routes["Marketplace Routes"]
  node_payment_routes["Payment Routes<br/>[payments.ts]"]
  node_mobile_routes["Mobile Routes<br/>[mobile.ts]"]
end

subgraph group_games["Chance Gaming"]
  node_chance["Chance Service<br/>[ChanceService.ts]"]
  node_rng["RNG Engine<br/>[RNGEngine.ts]"]
  node_probability["Probability Engine"]
  node_anti_cheat["Anti-cheat<br/>[AntiCheatSystem.ts]"]
  node_game_session[("Game Sessions<br/>[GameSession.ts]")]
  node_chance_audit[("Chance Audit<br/>[ChanceAudit.ts]")]
end

subgraph group_economy["Player Economy"]
  node_inventory_controller["Inventory Controller"]
  node_inventory_service["Inventory Service"]
  node_inventory_store[("Inventory Records<br/>[UserInventory.ts]")]
  node_item_store[("Item Catalog<br/>[Item.ts]")]
  node_market_service["Marketplace Service"]
  node_listing_store[("Listings")]
  node_payment_controller["Payment Controller"]
  node_payment_service["Payment Service<br/>[PaymentService.ts]"]
  node_payment_providers["Payment Providers"]
end

subgraph group_realtime["Realtime Play"]
  node_socket["Socket Service<br/>[SocketService.ts]"]
  node_socket_auth["Socket Authentication<br/>[socketAuth.ts]"]
end

subgraph group_platform["Platform Services"]
  node_user_service["User Service<br/>[UserService.ts]"]
  node_user_store[("User Records<br/>[User.ts]")]
  node_redis[("Redis")]
  node_mobile_service["Mobile Optimization"]
  node_monitoring["Monitoring"]
end

node_player(("Player"))

node_player -->|"sends requests"| node_server
node_server -->|"mounts routes"| node_game_routes
node_server -->|"mounts routes"| node_inventory_routes
node_server -->|"mounts routes"| node_market_routes
node_server -->|"mounts routes"| node_payment_routes
node_server -->|"mounts routes"| node_mobile_routes
node_game_routes -->|"calls"| node_chance
node_chance -->|"uses"| node_rng
node_chance -->|"uses"| node_probability
node_chance -->|"checks activity"| node_anti_cheat
node_chance -->|"saves sessions"| node_game_session
node_chance -->|"records outcomes"| node_chance_audit
node_probability -.->|"logs events"| node_chance_audit
node_inventory_routes -.->|"delegates"| node_inventory_controller
node_inventory_controller -->|"calls"| node_inventory_service
node_inventory_service -->|"updates"| node_inventory_store
node_inventory_service -->|"reads"| node_item_store
node_market_routes -.->|"uses"| node_market_service
node_market_service -->|"manages listings"| node_listing_store
node_market_service -->|"uses inventory"| node_inventory_store
node_market_service -->|"reads items"| node_item_store
node_payment_routes -.->|"delegates"| node_payment_controller
node_payment_controller -->|"calls"| node_payment_service
node_payment_service -.->|"integrates"| node_payment_providers
node_user_service -->|"manages users"| node_user_store
node_player -->|"opens connection"| node_socket
node_server -->|"initializes"| node_socket
node_socket -->|"dispatches games"| node_chance
node_socket -->|"authenticates"| node_socket_auth
node_socket -->|"uses inventory"| node_inventory_service
node_server -->|"configures adapter"| node_redis
node_mobile_routes -->|"uses"| node_mobile_service
node_monitoring -.->|"tracks activity"| node_chance_audit

click node_server "https://github.com/antusantury/hoodiediamond/blob/main/src/server.ts"
click node_game_routes "https://github.com/antusantury/hoodiediamond/blob/main/src/routes/games.ts"
click node_chance "https://github.com/antusantury/hoodiediamond/blob/main/src/services/ChanceService.ts"
click node_rng "https://github.com/antusantury/hoodiediamond/blob/main/src/services/RNGEngine.ts"
click node_probability "https://github.com/antusantury/hoodiediamond/blob/main/src/services/ProbabilityEngine.ts"
click node_anti_cheat "https://github.com/antusantury/hoodiediamond/blob/main/src/services/AntiCheatSystem.ts"
click node_game_session "https://github.com/antusantury/hoodiediamond/blob/main/src/models/GameSession.ts"
click node_chance_audit "https://github.com/antusantury/hoodiediamond/blob/main/src/models/ChanceAudit.ts"
click node_inventory_routes "https://github.com/antusantury/hoodiediamond/blob/main/src/routes/inventory.ts"
click node_inventory_controller "https://github.com/antusantury/hoodiediamond/blob/main/src/controllers/InventoryController.ts"
click node_inventory_service "https://github.com/antusantury/hoodiediamond/blob/main/src/services/InventoryService.ts"
click node_inventory_store "https://github.com/antusantury/hoodiediamond/blob/main/src/models/UserInventory.ts"
click node_item_store "https://github.com/antusantury/hoodiediamond/blob/main/src/models/Item.ts"
click node_market_routes "https://github.com/antusantury/hoodiediamond/blob/main/src/routes/marketplaceEnhanced.ts"
click node_market_service "https://github.com/antusantury/hoodiediamond/blob/main/src/services/MarketplaceService.ts"
click node_listing_store "https://github.com/antusantury/hoodiediamond/blob/main/src/models/MarketplaceListing.ts"
click node_payment_routes "https://github.com/antusantury/hoodiediamond/blob/main/src/routes/payments.ts"
click node_payment_controller "https://github.com/antusantury/hoodiediamond/blob/main/src/controllers/PaymentController.ts"
click node_payment_service "https://github.com/antusantury/hoodiediamond/blob/main/src/services/PaymentService.ts"
click node_user_service "https://github.com/antusantury/hoodiediamond/blob/main/src/services/UserService.ts"
click node_user_store "https://github.com/antusantury/hoodiediamond/blob/main/src/models/User.ts"
click node_socket "https://github.com/antusantury/hoodiediamond/blob/main/src/services/SocketService.ts"
click node_socket_auth "https://github.com/antusantury/hoodiediamond/blob/main/src/middleware/socketAuth.ts"
click node_mobile_routes "https://github.com/antusantury/hoodiediamond/blob/main/src/routes/mobile.ts"
click node_mobile_service "https://github.com/antusantury/hoodiediamond/blob/main/src/services/MobileOptimizationService.ts"
click node_monitoring "https://github.com/antusantury/hoodiediamond/blob/main/src/services/MonitoringService.ts"

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_server,node_game_routes,node_inventory_routes,node_market_routes,node_payment_routes,node_mobile_routes toneBlue
class node_chance,node_rng,node_probability,node_anti_cheat,node_game_session,node_chance_audit toneAmber
class node_inventory_controller,node_inventory_service,node_inventory_store,node_item_store,node_market_service,node_listing_store,node_payment_controller,node_payment_service,node_payment_providers toneMint
class node_socket,node_socket_auth toneRose
class node_user_service,node_user_store,node_redis,node_mobile_service,node_monitoring,node_player toneIndigo
```

## Components

### Runtime API

- [HTTP Server](https://github.com/antusantury/hoodiediamond/blob/main/src/server.ts): `src/server.ts`
- [Game Routes](https://github.com/antusantury/hoodiediamond/blob/main/src/routes/games.ts): `src/routes/games.ts`
- [Inventory Routes](https://github.com/antusantury/hoodiediamond/blob/main/src/routes/inventory.ts): `src/routes/inventory.ts`
- [Marketplace Routes](https://github.com/antusantury/hoodiediamond/blob/main/src/routes/marketplaceEnhanced.ts): `src/routes/marketplaceEnhanced.ts`
- [Payment Routes](https://github.com/antusantury/hoodiediamond/blob/main/src/routes/payments.ts): `src/routes/payments.ts`
- [Mobile Routes](https://github.com/antusantury/hoodiediamond/blob/main/src/routes/mobile.ts): `src/routes/mobile.ts`

### Chance Gaming

- [Chance Service](https://github.com/antusantury/hoodiediamond/blob/main/src/services/ChanceService.ts): `src/services/ChanceService.ts`
- [RNG Engine](https://github.com/antusantury/hoodiediamond/blob/main/src/services/RNGEngine.ts): `src/services/RNGEngine.ts`
- [Probability Engine](https://github.com/antusantury/hoodiediamond/blob/main/src/services/ProbabilityEngine.ts): `src/services/ProbabilityEngine.ts`
- [Anti-cheat](https://github.com/antusantury/hoodiediamond/blob/main/src/services/AntiCheatSystem.ts): `src/services/AntiCheatSystem.ts`
- [Game Sessions](https://github.com/antusantury/hoodiediamond/blob/main/src/models/GameSession.ts): `src/models/GameSession.ts`
- [Chance Audit](https://github.com/antusantury/hoodiediamond/blob/main/src/models/ChanceAudit.ts): `src/models/ChanceAudit.ts`

### Player Economy

- [Inventory Controller](https://github.com/antusantury/hoodiediamond/blob/main/src/controllers/InventoryController.ts): `src/controllers/InventoryController.ts`
- [Inventory Service](https://github.com/antusantury/hoodiediamond/blob/main/src/services/InventoryService.ts): `src/services/InventoryService.ts`
- [Inventory Records](https://github.com/antusantury/hoodiediamond/blob/main/src/models/UserInventory.ts): `src/models/UserInventory.ts`
- [Item Catalog](https://github.com/antusantury/hoodiediamond/blob/main/src/models/Item.ts): `src/models/Item.ts`
- [Marketplace Service](https://github.com/antusantury/hoodiediamond/blob/main/src/services/MarketplaceService.ts): `src/services/MarketplaceService.ts`
- [Listings](https://github.com/antusantury/hoodiediamond/blob/main/src/models/MarketplaceListing.ts): `src/models/MarketplaceListing.ts`
- [Payment Controller](https://github.com/antusantury/hoodiediamond/blob/main/src/controllers/PaymentController.ts): `src/controllers/PaymentController.ts`
- [Payment Service](https://github.com/antusantury/hoodiediamond/blob/main/src/services/PaymentService.ts): `src/services/PaymentService.ts`
- **Payment Providers**

### Realtime Play

- [Socket Service](https://github.com/antusantury/hoodiediamond/blob/main/src/services/SocketService.ts): `src/services/SocketService.ts`
- [Socket Authentication](https://github.com/antusantury/hoodiediamond/blob/main/src/middleware/socketAuth.ts): `src/middleware/socketAuth.ts`

### Platform Services

- [User Service](https://github.com/antusantury/hoodiediamond/blob/main/src/services/UserService.ts): `src/services/UserService.ts`
- [User Records](https://github.com/antusantury/hoodiediamond/blob/main/src/models/User.ts): `src/models/User.ts`
- **Redis**
- [Mobile Optimization](https://github.com/antusantury/hoodiediamond/blob/main/src/services/MobileOptimizationService.ts): `src/services/MobileOptimizationService.ts`
- [Monitoring](https://github.com/antusantury/hoodiediamond/blob/main/src/services/MonitoringService.ts): `src/services/MonitoringService.ts`

### Other components

- **Player**

## Connections

- Player → HTTP Server: sends requests
- HTTP Server → Game Routes: mounts routes (evidence: `src/server.ts`)
- HTTP Server → Inventory Routes: mounts routes (evidence: `src/server.ts`)
- HTTP Server → Marketplace Routes: mounts routes (evidence: `src/server.ts`)
- HTTP Server → Payment Routes: mounts routes (evidence: `src/server.ts`)
- HTTP Server → Mobile Routes: mounts routes (evidence: `src/server.ts`)
- Game Routes → Chance Service: calls (evidence: `src/routes/games.ts`)
- Chance Service → RNG Engine: uses (evidence: `src/services/ChanceService.ts`)
- Chance Service → Probability Engine: uses (evidence: `src/services/ChanceService.ts`)
- Chance Service → Anti-cheat: checks activity (evidence: `src/services/ChanceService.ts`)
- Chance Service → Game Sessions: saves sessions (evidence: `src/services/ChanceService.ts`)
- Chance Service → Chance Audit: records outcomes (evidence: `src/services/ChanceService.ts`)
- Probability Engine → Chance Audit: logs events
- Inventory Routes → Inventory Controller: delegates
- Inventory Controller → Inventory Service: calls (evidence: `src/controllers/InventoryController.ts`)
- Inventory Service → Inventory Records: updates (evidence: `src/services/InventoryService.ts`)
- Inventory Service → Item Catalog: reads (evidence: `src/services/InventoryService.ts`)
- Marketplace Routes → Marketplace Service: uses
- Marketplace Service → Listings: manages listings (evidence: `src/services/MarketplaceService.ts`)
- Marketplace Service → Inventory Records: uses inventory (evidence: `src/services/MarketplaceService.ts`)
- Marketplace Service → Item Catalog: reads items (evidence: `src/services/MarketplaceService.ts`)
- Payment Routes → Payment Controller: delegates
- Payment Controller → Payment Service: calls (evidence: `src/controllers/PaymentController.ts`)
- Payment Service → Payment Providers: integrates
- User Service → User Records: manages users (evidence: `src/services/UserService.ts`)
- Player → Socket Service: opens connection
- HTTP Server → Socket Service: initializes (evidence: `src/server.ts`)
- Socket Service → Chance Service: dispatches games (evidence: `src/services/SocketService.ts`)
- Socket Service → Socket Authentication: authenticates (evidence: `src/services/SocketService.ts`)
- Socket Service → Inventory Service: uses inventory (evidence: `src/services/SocketService.ts`)
- HTTP Server → Redis: configures adapter (evidence: `src/server.ts`)
- Mobile Routes → Mobile Optimization: uses (evidence: `src/routes/mobile.ts`)
- Monitoring → Chance Audit: tracks activity
