# gizzzmo/cassanova architecture

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

- Interactive diagram: https://gitdiagram.com/gizzzmo/cassanova
- Repository: https://github.com/gizzzmo/cassanova

## Overview

#### Purpose and topology
Cassanova is an educational full-stack casino platform: a Next.js customer UI consumes an Express REST API backed by MongoDB. It covers account lifecycle, game/promotional catalog browsing, wallet transactions, KYC-gated withdrawals, and responsible-gaming settings. Real payment and game-provider integrations are explicitly future work.

#### Application entry points
- Frontend App Router root and global shell: `frontend/app/layout.tsx`, with the landing experience at `frontend/app/page.tsx`.
- Backend HTTP process: `backend/src/server.ts`; it owns Express setup, API route mounting, MongoDB connectivity, CORS, and server startup.
- Frontend-to-backend boundary is centralized in `frontend/lib/api.ts`; client authentication/session state is provided by `frontend/lib/auth-context.tsx`.

#### Frontend route composition
The Next.js application separates public catalog/marketing routes from authenticated account and wallet journeys. Dynamic detail routes resolve game and promotion slugs via `frontend/app/games/[slug]/page.tsx` and `frontend/app/promotions/[slug]/page.tsx`. Account-facing flows are routed through `frontend/app/dashboard/page.tsx`, `frontend/app/deposit/page.tsx`, and `frontend/app/withdraw/page.tsx`. Shared navigation frames content through `frontend/components/layout/Header.tsx` and `frontend/components/layout/Footer.tsx`.

#### Identity and authorization
Authentication is JWT-based: registration/login handlers issue credentials, while passwords are protected with bcrypt. API protection occurs at the Express middleware boundary before protected user and financial operations: `backend/src/controllers/auth.controller.ts`, `backend/src/middleware/auth.middleware.ts`, and `backend/src/routes/auth.routes.ts`. The frontend auth context persists session state and drives protected-route redirects; backend authorization remains the trust boundary.

#### Domain persistence and API layers
Mongoose models define the central MongoDB records: user/account and KYC or gaming state in `backend/src/models/User.ts`, catalog metadata in `backend/src/models/Game.ts`, and wallet audit records in `backend/src/models/Transaction.ts`. Express routes map resource endpoints to controllers, keeping HTTP wiring separate from operation logic; examples include `backend/src/routes/game.routes.ts`, `backend/src/controllers/game.controller.ts`, and `backend/src/controllers/promotion.controller.ts`.

#### Financial and compliance flow
Deposit and withdrawal requests enter transaction routes/controllers, validate authenticated user state and balance-related constraints, then create transaction history and update account state. Withdrawal is additionally KYC-gated; transaction operations are an internal application workflow, not an implemented external payment settlement integration. Primary locations: `backend/src/routes/transaction.routes.ts`, `backend/src/controllers/transaction.controller.ts`, `backend/src/models/Transaction.ts`.

#### Runtime and delivery boundaries
Frontend runtime is Next.js 15/React 19/TypeScript with Tailwind CSS; backend is Node.js 20+, Express 5, TypeScript, MongoDB 8/Mongoose, JWT, and bcryptjs. MongoDB may be local or Atlas and is configured through backend environment values, represented by `backend/.env.example`. CI builds backend TypeScript and lints/builds the frontend in ` .github/workflows/ci.yml`; deployment exists only as an opt-in template at `.github/workflows/deploy.yml.template`.

Main entry points: [`backend/src/server.ts`](https://github.com/gizzzmo/cassanova/blob/main/backend/src/server.ts) (Express server), [`frontend/app/layout.tsx`](https://github.com/gizzzmo/cassanova/blob/main/frontend/app/layout.tsx) (App shell & landing), [`frontend/lib/api.ts`](https://github.com/gizzzmo/cassanova/blob/main/frontend/lib/api.ts) (API client), [`frontend/app/dashboard/page.tsx`](https://github.com/gizzzmo/cassanova/blob/main/frontend/app/dashboard/page.tsx) (Account & wallet routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Next.js frontend"]
  node_web_shell["App shell &amp; landing<br/>Next.js routes<br/>[layout.tsx]"]
  node_catalog_routes["Catalog detail routes<br/>Next.js dynamic routes<br/>[page.tsx]"]
  node_account_routes["Account &amp; wallet routes<br/>Next.js routes<br/>[page.tsx]"]
  node_shared_navigation["Header &amp; footer<br/>React layout<br/>[Header.tsx]"]
  node_api_client{{"API client<br/>frontend API boundary<br/>[api.ts]"}}
  node_auth_context["Auth context<br/>client session state<br/>[auth-context.tsx]"]
end

subgraph group_backend["Express backend"]
  node_server["Express server<br/>HTTP process<br/>[server.ts]"]
  node_auth_routes["Auth routes<br/>Express routes<br/>[auth.routes.ts]"]
  node_auth_controller["Auth controller<br/>identity operations<br/>[auth.controller.ts]"]
  node_auth_middleware{{"JWT auth middleware<br/>authorization boundary<br/>[auth.middleware.ts]"}}
  node_catalog_routes_api["Game routes<br/>Express routes<br/>[game.routes.ts]"]
  node_game_controller["Game controller<br/>catalog operations<br/>[game.controller.ts]"]
  node_promotion_controller["Promotion controller<br/>catalog operations"]
  node_transaction_routes["Transaction routes<br/>Express routes"]
  node_transaction_controller["Transaction controller<br/>wallet workflow"]
end

subgraph group_data["Persistence"]
  node_users["User records<br/>Mongoose model<br/>[User.ts]"]
  node_games["Game catalog<br/>Mongoose model<br/>[Game.ts]"]
  node_transactions["Transaction ledger<br/>Mongoose model<br/>[Transaction.ts]"]
  node_mongodb[("MongoDB<br/>database<br/>[.env.example]")]
end

subgraph group_delivery["Delivery"]
  node_ci["CI workflow<br/>GitHub Actions<br/>[ci.yml]"]
  node_deploy_template["Deploy template<br/>GitHub Actions template"]
end

node_web_shell -->|"frames"| node_shared_navigation
node_web_shell -->|"links to"| node_catalog_routes
node_web_shell -->|"links to"| node_account_routes
node_account_routes -->|"uses session"| node_auth_context
node_auth_context -->|"supplies JWT"| node_api_client
node_catalog_routes -->|"loads catalog"| node_api_client
node_account_routes -->|"account requests"| node_api_client
node_api_client -->|"REST API"| node_server
node_server -->|"mounts"| node_auth_routes
node_server -->|"mounts"| node_catalog_routes_api
node_server -->|"mounts"| node_transaction_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_controller -->|"creates/authenticates"| node_users
node_catalog_routes_api -->|"dispatches"| node_game_controller
node_game_controller -->|"reads"| node_games
node_promotion_controller -->|"serves catalog"| node_games
node_transaction_routes -->|"requires"| node_auth_middleware
node_auth_middleware -->|"authorizes"| node_transaction_controller
node_transaction_controller -->|"checks KYC and balance"| node_users
node_transaction_controller -->|"creates history"| node_transactions
node_users -->|"persists"| node_mongodb
node_games -->|"persists"| node_mongodb
node_transactions -->|"persists"| node_mongodb
node_ci -.->|"lints and builds"| node_web_shell
node_ci -.->|"builds TypeScript"| node_server
node_deploy_template -.->|"deployment option"| node_server

click node_web_shell "https://github.com/gizzzmo/cassanova/blob/main/frontend/app/layout.tsx"
click node_catalog_routes "https://github.com/gizzzmo/cassanova/blob/main/frontend/app/games/%5Bslug%5D/page.tsx"
click node_account_routes "https://github.com/gizzzmo/cassanova/blob/main/frontend/app/dashboard/page.tsx"
click node_shared_navigation "https://github.com/gizzzmo/cassanova/blob/main/frontend/components/layout/Header.tsx"
click node_api_client "https://github.com/gizzzmo/cassanova/blob/main/frontend/lib/api.ts"
click node_auth_context "https://github.com/gizzzmo/cassanova/blob/main/frontend/lib/auth-context.tsx"
click node_server "https://github.com/gizzzmo/cassanova/blob/main/backend/src/server.ts"
click node_auth_routes "https://github.com/gizzzmo/cassanova/blob/main/backend/src/routes/auth.routes.ts"
click node_auth_controller "https://github.com/gizzzmo/cassanova/blob/main/backend/src/controllers/auth.controller.ts"
click node_auth_middleware "https://github.com/gizzzmo/cassanova/blob/main/backend/src/middleware/auth.middleware.ts"
click node_catalog_routes_api "https://github.com/gizzzmo/cassanova/blob/main/backend/src/routes/game.routes.ts"
click node_game_controller "https://github.com/gizzzmo/cassanova/blob/main/backend/src/controllers/game.controller.ts"
click node_promotion_controller "https://github.com/gizzzmo/cassanova/blob/main/backend/src/controllers/promotion.controller.ts"
click node_transaction_routes "https://github.com/gizzzmo/cassanova/blob/main/backend/src/routes/transaction.routes.ts"
click node_transaction_controller "https://github.com/gizzzmo/cassanova/blob/main/backend/src/controllers/transaction.controller.ts"
click node_users "https://github.com/gizzzmo/cassanova/blob/main/backend/src/models/User.ts"
click node_games "https://github.com/gizzzmo/cassanova/blob/main/backend/src/models/Game.ts"
click node_transactions "https://github.com/gizzzmo/cassanova/blob/main/backend/src/models/Transaction.ts"
click node_mongodb "https://github.com/gizzzmo/cassanova/blob/main/backend/.env.example"
click node_ci "https://github.com/gizzzmo/cassanova/blob/main/.github/workflows/ci.yml"
click node_deploy_template "https://github.com/gizzzmo/cassanova/blob/main/.github/workflows/deploy.yml.template"

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_web_shell,node_catalog_routes,node_account_routes,node_shared_navigation,node_api_client,node_auth_context toneBlue
class node_server,node_auth_routes,node_auth_controller,node_auth_middleware,node_catalog_routes_api,node_game_controller,node_promotion_controller,node_transaction_routes,node_transaction_controller toneAmber
class node_users,node_games,node_transactions,node_mongodb toneMint
class node_ci,node_deploy_template toneRose
```

## Components

### Next.js frontend

- [App shell & landing](https://github.com/gizzzmo/cassanova/blob/main/frontend/app/layout.tsx): Next.js routes · App Router root hosts the public landing experience. · `frontend/app/layout.tsx`
- [Catalog detail routes](https://github.com/gizzzmo/cassanova/blob/main/frontend/app/games/%5Bslug%5D/page.tsx): Next.js dynamic routes · Game and promotion pages resolve catalog slugs. · `frontend/app/games/[slug]/page.tsx`
- [Account & wallet routes](https://github.com/gizzzmo/cassanova/blob/main/frontend/app/dashboard/page.tsx): Next.js routes · Dashboard, deposit, and withdrawal journeys. · `frontend/app/dashboard/page.tsx`
- [Header & footer](https://github.com/gizzzmo/cassanova/blob/main/frontend/components/layout/Header.tsx): React layout · `frontend/components/layout/Header.tsx`
- [API client](https://github.com/gizzzmo/cassanova/blob/main/frontend/lib/api.ts): frontend API boundary · Centralized frontend-to-backend REST access. · `frontend/lib/api.ts`
- [Auth context](https://github.com/gizzzmo/cassanova/blob/main/frontend/lib/auth-context.tsx): client session state · Persists session state and redirects protected routes. · `frontend/lib/auth-context.tsx`

### Express backend

- [Express server](https://github.com/gizzzmo/cassanova/blob/main/backend/src/server.ts): HTTP process · Configures Express, CORS, MongoDB connectivity, routes, and startup. · `backend/src/server.ts`
- [Auth routes](https://github.com/gizzzmo/cassanova/blob/main/backend/src/routes/auth.routes.ts): Express routes · `backend/src/routes/auth.routes.ts`
- [Auth controller](https://github.com/gizzzmo/cassanova/blob/main/backend/src/controllers/auth.controller.ts): identity operations · Registration and login issue JWT credentials and protect passwords with bcrypt. · `backend/src/controllers/auth.controller.ts`
- [JWT auth middleware](https://github.com/gizzzmo/cassanova/blob/main/backend/src/middleware/auth.middleware.ts): authorization boundary · Protects user and financial operations. · `backend/src/middleware/auth.middleware.ts`
- [Game routes](https://github.com/gizzzmo/cassanova/blob/main/backend/src/routes/game.routes.ts): Express routes · `backend/src/routes/game.routes.ts`
- [Game controller](https://github.com/gizzzmo/cassanova/blob/main/backend/src/controllers/game.controller.ts): catalog operations · `backend/src/controllers/game.controller.ts`
- [Promotion controller](https://github.com/gizzzmo/cassanova/blob/main/backend/src/controllers/promotion.controller.ts): catalog operations · `backend/src/controllers/promotion.controller.ts`
- [Transaction routes](https://github.com/gizzzmo/cassanova/blob/main/backend/src/routes/transaction.routes.ts): Express routes · `backend/src/routes/transaction.routes.ts`
- [Transaction controller](https://github.com/gizzzmo/cassanova/blob/main/backend/src/controllers/transaction.controller.ts): wallet workflow · Validates balances; withdrawals require KYC; no external settlement is implemented. · `backend/src/controllers/transaction.controller.ts`

### Persistence

- [User records](https://github.com/gizzzmo/cassanova/blob/main/backend/src/models/User.ts): Mongoose model · Accounts, KYC, and gaming state. · `backend/src/models/User.ts`
- [Game catalog](https://github.com/gizzzmo/cassanova/blob/main/backend/src/models/Game.ts): Mongoose model · `backend/src/models/Game.ts`
- [Transaction ledger](https://github.com/gizzzmo/cassanova/blob/main/backend/src/models/Transaction.ts): Mongoose model · Wallet audit records. · `backend/src/models/Transaction.ts`
- [MongoDB](https://github.com/gizzzmo/cassanova/blob/main/backend/.env.example): database · Local or Atlas deployment configured through backend environment values. · `backend/.env.example`

### Delivery

- [CI workflow](https://github.com/gizzzmo/cassanova/blob/main/.github/workflows/ci.yml): GitHub Actions · Builds backend TypeScript and lints/builds the frontend. · `.github/workflows/ci.yml`
- [Deploy template](https://github.com/gizzzmo/cassanova/blob/main/.github/workflows/deploy.yml.template): GitHub Actions template · Opt-in deployment template. · `.github/workflows/deploy.yml.template`

## Connections

- App shell & landing → Header & footer: frames
- App shell & landing → Catalog detail routes: links to
- App shell & landing → Account & wallet routes: links to
- Account & wallet routes → Auth context: uses session
- Auth context → API client: supplies JWT
- Catalog detail routes → API client: loads catalog
- Account & wallet routes → API client: account requests
- API client → Express server: REST API
- Express server → Auth routes: mounts
- Express server → Game routes: mounts
- Express server → Transaction routes: mounts
- Auth routes → Auth controller: dispatches
- Auth controller → User records: creates/authenticates
- Game routes → Game controller: dispatches
- Game controller → Game catalog: reads
- Promotion controller → Game catalog: serves catalog
- Transaction routes → JWT auth middleware: requires
- JWT auth middleware → Transaction controller: authorizes
- Transaction controller → User records: checks KYC and balance
- Transaction controller → Transaction ledger: creates history
- User records → MongoDB: persists
- Game catalog → MongoDB: persists
- Transaction ledger → MongoDB: persists
- CI workflow → App shell & landing: lints and builds
- CI workflow → Express server: builds TypeScript
- Deploy template → Express server: deployment option
