# alexg-7be/sevenbet-next architecture

> Architecture diagram of the GitHub repository alexg-7be/sevenbet-next, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alexg-7be/sevenbet-next
- Repository: https://github.com/alexg-7be/sevenbet-next

## Overview

B4GAMBLE is a responsible-gambling decision-support platform: its primary journey leads adults from public information into a private, control-first 10-Step Programme, while casino and bonus discovery remain secondary. Separate product branches cover learning, non-commercial Protected Help, and private control tools; commercial actions use a governed handoff. Staff use protected admin workflows to manage published content and commercial data. The README documents these capabilities; sampled code confirms programme persistence and editorial review/repository behavior, but does not expose every route’s wiring.

Main entry points: [`app/(public)`](https://github.com/alexg-7be/sevenbet-next/tree/main/app/(public)) (Public site), [`app/api/program`](https://github.com/alexg-7be/sevenbet-next/tree/main/app/api/program) (Programme APIs), [`app/r/[slug]/route.ts`](https://github.com/alexg-7be/sevenbet-next/blob/main/app/r/%5Bslug%5D/route.ts) (Managed redirect), [`app/admin/(protected)`](https://github.com/alexg-7be/sevenbet-next/tree/main/app/admin/(protected)) (Admin workbenches)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public discovery"]
  node_public_site["Public site"]
  node_learning["Learning center"]
  node_protected_help["Protected Help"]
  node_control_tools["Control tools"]
  node_casino_discovery["Casino discovery"]
end

subgraph group_programme["Private programme"]
  node_programme_ui["Programme experience"]
  node_programme_api["Programme APIs"]
  node_journey_storage["Local journey storage"]
  node_account_access["Programme access"]
end

subgraph group_editorial["Editorial and CMS"]
  node_program_service["Programme service<br/>[program.service.ts]"]
  node_program_repository["Programme repository"]
  node_editorial_service["Editorial review service"]
  node_editorial_repository["Editorial review repository"]
end

subgraph group_commercial["Commercial handoff"]
  node_commercial_ui["Commercial confirmation UI"]
  node_redirect["Managed redirect<br/>[route.ts]"]
  node_unavailable["Neutral recovery<br/>[page.tsx]"]
end

subgraph group_operations["Staff operations"]
  node_admin_ui["Admin workbenches"]
  node_admin_api["Admin APIs"]
  node_staff_auth["Staff authentication<br/>[admin.ts]"]
end

node_adult(("Adult visitor"))
node_staff(("Staff user"))
node_database[("PostgreSQL database")]
node_affiliate_partner["Affiliate destination"]

node_adult -->|"browses"| node_public_site
node_public_site -->|"offers learning"| node_learning
node_public_site -->|"offers support"| node_protected_help
node_public_site -->|"offers control tools"| node_control_tools
node_public_site -->|"offers discovery"| node_casino_discovery
node_adult -->|"starts programme"| node_programme_ui
node_programme_ui -->|"requests journey"| node_programme_api
node_programme_api -->|"stores locally"| node_journey_storage
node_programme_api -->|"checks access"| node_account_access
node_staff -->|"manages content"| node_admin_ui
node_admin_ui -->|"checks identity"| node_staff_auth
node_admin_ui -->|"sends changes"| node_admin_api
node_admin_api -->|"manages programmes"| node_program_service
node_program_service -->|"reads and writes"| node_program_repository
node_program_repository -->|"queries programmes"| node_database
node_admin_api -->|"manages reviews"| node_editorial_service
node_editorial_service -->|"validates and transitions"| node_editorial_repository
node_editorial_repository -->|"reads and writes reviews"| node_database
node_adult -->|"confirms offer"| node_commercial_ui
node_commercial_ui -->|"opens managed route"| node_redirect
node_redirect -->|"redirects when eligible"| node_affiliate_partner
node_redirect -->|"recovers on failure"| node_unavailable

click node_public_site "https://github.com/alexg-7be/sevenbet-next/tree/main/app/(public)"
click node_learning "https://github.com/alexg-7be/sevenbet-next/tree/main/app/(public)/learn"
click node_protected_help "https://github.com/alexg-7be/sevenbet-next/tree/main/app/help"
click node_control_tools "https://github.com/alexg-7be/sevenbet-next/tree/main/app/(public)/self-check"
click node_casino_discovery "https://github.com/alexg-7be/sevenbet-next/blob/main/components/casino-discovery/CasinoCollection.tsx"
click node_programme_ui "https://github.com/alexg-7be/sevenbet-next/blob/main/components/programme/ProgramAiExperience.tsx"
click node_programme_api "https://github.com/alexg-7be/sevenbet-next/tree/main/app/api/program"
click node_journey_storage "https://github.com/alexg-7be/sevenbet-next/blob/main/lib/programme/local-subject-storage.ts"
click node_account_access "https://github.com/alexg-7be/sevenbet-next/blob/main/lib/auth/programme-user-access.ts"
click node_admin_ui "https://github.com/alexg-7be/sevenbet-next/tree/main/app/admin/(protected)"
click node_admin_api "https://github.com/alexg-7be/sevenbet-next/tree/main/app/api/admin"
click node_staff_auth "https://github.com/alexg-7be/sevenbet-next/blob/main/lib/auth/admin.ts"
click node_program_service "https://github.com/alexg-7be/sevenbet-next/blob/main/lib/services/program.service.ts"
click node_program_repository "https://github.com/alexg-7be/sevenbet-next/blob/main/lib/repositories/program.repository.ts"
click node_editorial_service "https://github.com/alexg-7be/sevenbet-next/blob/main/lib/services/editorial-review.service.ts"
click node_editorial_repository "https://github.com/alexg-7be/sevenbet-next/blob/main/lib/repositories/editorial-review.repository.ts"
click node_commercial_ui "https://github.com/alexg-7be/sevenbet-next/blob/main/components/commercial-handoff/CommercialHandoffPage.tsx"
click node_redirect "https://github.com/alexg-7be/sevenbet-next/blob/main/app/r/%5Bslug%5D/route.ts"
click node_unavailable "https://github.com/alexg-7be/sevenbet-next/blob/main/app/(public)/outbound/unavailable/page.tsx"

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_public_site,node_learning,node_protected_help,node_control_tools,node_casino_discovery,node_staff toneBlue
class node_programme_ui,node_programme_api,node_journey_storage,node_account_access,node_database toneAmber
class node_program_service,node_program_repository,node_editorial_service,node_editorial_repository toneMint
class node_commercial_ui,node_redirect,node_unavailable toneRose
class node_admin_ui,node_admin_api,node_staff_auth,node_adult,node_affiliate_partner toneIndigo
```

## Components

### Public discovery

- [Public site](https://github.com/alexg-7be/sevenbet-next/tree/main/app/(public)): `app/(public)`
- [Learning center](https://github.com/alexg-7be/sevenbet-next/tree/main/app/(public)/learn): `app/(public)/learn`
- [Protected Help](https://github.com/alexg-7be/sevenbet-next/tree/main/app/help): `app/help`
- [Control tools](https://github.com/alexg-7be/sevenbet-next/tree/main/app/(public)/self-check): `app/(public)/self-check`
- [Casino discovery](https://github.com/alexg-7be/sevenbet-next/blob/main/components/casino-discovery/CasinoCollection.tsx): `components/casino-discovery/CasinoCollection.tsx`

### Private programme

- [Programme experience](https://github.com/alexg-7be/sevenbet-next/blob/main/components/programme/ProgramAiExperience.tsx): `components/programme/ProgramAiExperience.tsx`
- [Programme APIs](https://github.com/alexg-7be/sevenbet-next/tree/main/app/api/program): `app/api/program`
- [Local journey storage](https://github.com/alexg-7be/sevenbet-next/blob/main/lib/programme/local-subject-storage.ts): `lib/programme/local-subject-storage.ts`
- [Programme access](https://github.com/alexg-7be/sevenbet-next/blob/main/lib/auth/programme-user-access.ts): `lib/auth/programme-user-access.ts`

### Editorial and CMS

- [Programme service](https://github.com/alexg-7be/sevenbet-next/blob/main/lib/services/program.service.ts): `lib/services/program.service.ts`
- [Programme repository](https://github.com/alexg-7be/sevenbet-next/blob/main/lib/repositories/program.repository.ts): `lib/repositories/program.repository.ts`
- [Editorial review service](https://github.com/alexg-7be/sevenbet-next/blob/main/lib/services/editorial-review.service.ts): `lib/services/editorial-review.service.ts`
- [Editorial review repository](https://github.com/alexg-7be/sevenbet-next/blob/main/lib/repositories/editorial-review.repository.ts): `lib/repositories/editorial-review.repository.ts`

### Commercial handoff

- [Commercial confirmation UI](https://github.com/alexg-7be/sevenbet-next/blob/main/components/commercial-handoff/CommercialHandoffPage.tsx): `components/commercial-handoff/CommercialHandoffPage.tsx`
- [Managed redirect](https://github.com/alexg-7be/sevenbet-next/blob/main/app/r/%5Bslug%5D/route.ts): `app/r/[slug]/route.ts`
- [Neutral recovery](https://github.com/alexg-7be/sevenbet-next/blob/main/app/(public)/outbound/unavailable/page.tsx): `app/(public)/outbound/unavailable/page.tsx`

### Staff operations

- [Admin workbenches](https://github.com/alexg-7be/sevenbet-next/tree/main/app/admin/(protected)): `app/admin/(protected)`
- [Admin APIs](https://github.com/alexg-7be/sevenbet-next/tree/main/app/api/admin): `app/api/admin`
- [Staff authentication](https://github.com/alexg-7be/sevenbet-next/blob/main/lib/auth/admin.ts): `lib/auth/admin.ts`

### Other components

- **Adult visitor**
- **Staff user**
- **PostgreSQL database**
- **Affiliate destination**

## Connections

- Adult visitor → Public site: browses
- Public site → Learning center: offers learning
- Public site → Protected Help: offers support
- Public site → Control tools: offers control tools
- Public site → Casino discovery: offers discovery
- Adult visitor → Programme experience: starts programme
- Programme experience → Programme APIs: requests journey
- Programme APIs → Local journey storage: stores locally
- Programme APIs → Programme access: checks access
- Staff user → Admin workbenches: manages content
- Admin workbenches → Staff authentication: checks identity
- Admin workbenches → Admin APIs: sends changes
- Admin APIs → Programme service: manages programmes
- Programme service → Programme repository: reads and writes
- Programme repository → PostgreSQL database: queries programmes
- Admin APIs → Editorial review service: manages reviews
- Editorial review service → Editorial review repository: validates and transitions
- Editorial review repository → PostgreSQL database: reads and writes reviews
- Adult visitor → Commercial confirmation UI: confirms offer
- Commercial confirmation UI → Managed redirect: opens managed route
- Managed redirect → Affiliate destination: redirects when eligible
- Managed redirect → Neutral recovery: recovers on failure
