# hungryelderberry/nexus-video-games architecture

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

- Interactive diagram: https://gitdiagram.com/hungryelderberry/nexus-video-games
- Repository: https://github.com/hungryelderberry/nexus-video-games

## Overview

Nexus Video Games is a Go REST API for account access, a game catalog and wallet, payment top-ups, and single-game sessions. Its user-facing flow runs from HTTP endpoints through controllers and use cases to PostgreSQL-backed repositories, with external catalog, payment, and email capabilities documented by the README. The sampled bootstrap shows dependency construction and route setup; sampled handlers and session logic show selected call paths. Other subsystem links are omitted where their source calls were not excerpted.

Main entry points: [`internal/config/app.go`](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/config/app.go) (Composition root), [`internal/usecase/session_usecase.go`](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/usecase/session_usecase.go) (Game sessions), [`internal/repository/postgresql/game_repository.go`](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/repository/postgresql/game_repository.go) (Game repository), [`internal/repository/postgresql/session_repository.go`](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/repository/postgresql/session_repository.go) (Session repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_delivery["HTTP delivery"]
  node_bootstrap["Composition root<br/>[app.go]"]
  node_user_http["Account endpoints<br/>[user_controller.go]"]
  node_balance_http["Wallet endpoints"]
  node_game_http["Game endpoints<br/>[game_controller.go]"]
  node_session_http["Session endpoints"]
  node_dashboard_http["Dashboard endpoint"]
  node_http_routes["HTTP routing<br/>[route.go]"]
end

subgraph group_domain["Business workflows"]
  node_user_flow["Account workflow<br/>[user_usecase.go]"]
  node_balance_flow["Wallet and top-ups<br/>[balance_usecase.go]"]
  node_game_flow["Catalog and ownership<br/>[game_usecase.go]"]
  node_session_flow["Game sessions<br/>[session_usecase.go]"]
  node_dashboard_flow["Dashboard aggregation"]
end

subgraph group_persistence["Persistence"]
  node_postgres[("PostgreSQL")]
  node_user_repo["User repository<br/>[user_repository.go]"]
  node_balance_repo["Balance repository"]
  node_topup_repo["Top-up repository"]
  node_game_repo["Game repository<br/>[game_repository.go]"]
  node_session_repo["Session repository"]
end

subgraph group_integrations["External integrations"]
  node_resend["Resend email<br/>[resend_gateway.go]"]
  node_xendit["Xendit payments<br/>[xendit_gateway.go]"]
  node_itad["ITAD catalog<br/>[itad_gateway.go]"]
end

subgraph group_security["Identity and security"]
  node_auth_middleware["JWT middleware<br/>[auth_middleware.go]"]
  node_jwt_service["JWT service<br/>[jwt.go]"]
end

node_player(("API client"))

node_player -->|"calls API"| node_http_routes
node_bootstrap -->|"sets up"| node_http_routes
node_bootstrap -->|"wires"| node_user_http
node_bootstrap -->|"wires"| node_balance_http
node_bootstrap -->|"wires"| node_game_http
node_bootstrap -->|"wires"| node_session_http
node_bootstrap -->|"wires"| node_dashboard_http
node_bootstrap -->|"constructs"| node_user_flow
node_bootstrap -->|"constructs"| node_balance_flow
node_bootstrap -->|"constructs"| node_game_flow
node_bootstrap -->|"constructs"| node_session_flow
node_bootstrap -->|"constructs"| node_dashboard_flow
node_user_http -->|"invokes"| node_user_flow
node_balance_http -->|"invokes"| node_balance_flow
node_game_http -->|"invokes"| node_game_flow
node_session_http -->|"invokes"| node_session_flow
node_session_flow -->|"checks ownership"| node_game_repo
node_session_flow -->|"checks and saves"| node_session_repo
node_session_flow -->|"updates playtime"| node_game_repo
node_session_repo -->|"reads and writes"| node_postgres
node_game_repo -->|"reads and writes"| node_postgres
node_bootstrap -->|"constructs"| node_user_repo
node_bootstrap -->|"constructs"| node_balance_repo
node_bootstrap -->|"constructs"| node_topup_repo
node_bootstrap -->|"constructs"| node_game_repo
node_bootstrap -->|"constructs"| node_session_repo
node_bootstrap -->|"constructs"| node_jwt_service
node_bootstrap -->|"constructs"| node_resend
node_bootstrap -->|"constructs"| node_xendit
node_bootstrap -->|"constructs"| node_itad

click node_bootstrap "https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/config/app.go"
click node_user_http "https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/delivery/http/controller/user_controller.go"
click node_balance_http "https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/delivery/http/controller/balance_controller.go"
click node_game_http "https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/delivery/http/controller/game_controller.go"
click node_session_http "https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/delivery/http/controller/session_controller.go"
click node_dashboard_http "https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/delivery/http/controller/dashboard_controller.go"
click node_http_routes "https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/delivery/http/route/route.go"
click node_auth_middleware "https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/delivery/http/middleware/auth_middleware.go"
click node_user_flow "https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/usecase/user_usecase.go"
click node_balance_flow "https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/usecase/balance_usecase.go"
click node_game_flow "https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/usecase/game_usecase.go"
click node_session_flow "https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/usecase/session_usecase.go"
click node_dashboard_flow "https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/usecase/dashboard_usecase.go"
click node_user_repo "https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/repository/postgresql/user_repository.go"
click node_balance_repo "https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/repository/postgresql/balance_repository.go"
click node_topup_repo "https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/repository/postgresql/topup_repository.go"
click node_game_repo "https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/repository/postgresql/game_repository.go"
click node_session_repo "https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/repository/postgresql/session_repository.go"
click node_resend "https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/gateway/email/resend_gateway.go"
click node_xendit "https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/gateway/payment/xendit_gateway.go"
click node_itad "https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/gateway/game/itad_gateway.go"
click node_jwt_service "https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/pkg/jwt/jwt.go"

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_bootstrap,node_user_http,node_balance_http,node_game_http,node_session_http,node_dashboard_http,node_http_routes,node_player toneBlue
class node_user_flow,node_balance_flow,node_game_flow,node_session_flow,node_dashboard_flow toneAmber
class node_postgres,node_user_repo,node_balance_repo,node_topup_repo,node_game_repo,node_session_repo toneMint
class node_resend,node_xendit,node_itad toneRose
class node_auth_middleware,node_jwt_service toneIndigo
```

## Components

### HTTP delivery

- [Composition root](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/config/app.go): `internal/config/app.go`
- [Account endpoints](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/delivery/http/controller/user_controller.go): `internal/delivery/http/controller/user_controller.go`
- [Wallet endpoints](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/delivery/http/controller/balance_controller.go): `internal/delivery/http/controller/balance_controller.go`
- [Game endpoints](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/delivery/http/controller/game_controller.go): `internal/delivery/http/controller/game_controller.go`
- [Session endpoints](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/delivery/http/controller/session_controller.go): `internal/delivery/http/controller/session_controller.go`
- [Dashboard endpoint](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/delivery/http/controller/dashboard_controller.go): `internal/delivery/http/controller/dashboard_controller.go`
- [HTTP routing](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/delivery/http/route/route.go): `internal/delivery/http/route/route.go`

### Business workflows

- [Account workflow](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/usecase/user_usecase.go): `internal/usecase/user_usecase.go`
- [Wallet and top-ups](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/usecase/balance_usecase.go): `internal/usecase/balance_usecase.go`
- [Catalog and ownership](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/usecase/game_usecase.go): `internal/usecase/game_usecase.go`
- [Game sessions](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/usecase/session_usecase.go): `internal/usecase/session_usecase.go`
- [Dashboard aggregation](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/usecase/dashboard_usecase.go): `internal/usecase/dashboard_usecase.go`

### Persistence

- **PostgreSQL**
- [User repository](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/repository/postgresql/user_repository.go): `internal/repository/postgresql/user_repository.go`
- [Balance repository](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/repository/postgresql/balance_repository.go): `internal/repository/postgresql/balance_repository.go`
- [Top-up repository](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/repository/postgresql/topup_repository.go): `internal/repository/postgresql/topup_repository.go`
- [Game repository](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/repository/postgresql/game_repository.go): `internal/repository/postgresql/game_repository.go`
- [Session repository](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/repository/postgresql/session_repository.go): `internal/repository/postgresql/session_repository.go`

### External integrations

- [Resend email](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/gateway/email/resend_gateway.go): `internal/gateway/email/resend_gateway.go`
- [Xendit payments](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/gateway/payment/xendit_gateway.go): `internal/gateway/payment/xendit_gateway.go`
- [ITAD catalog](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/gateway/game/itad_gateway.go): `internal/gateway/game/itad_gateway.go`

### Identity and security

- [JWT middleware](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/delivery/http/middleware/auth_middleware.go): `internal/delivery/http/middleware/auth_middleware.go`
- [JWT service](https://github.com/hungryelderberry/nexus-video-games/blob/main/internal/pkg/jwt/jwt.go): `internal/pkg/jwt/jwt.go`

### Other components

- **API client**

## Connections

- API client → HTTP routing: calls API (evidence: `README.md`)
- Composition root → HTTP routing: sets up (evidence: `internal/config/app.go`)
- Composition root → Account endpoints: wires (evidence: `internal/config/app.go`)
- Composition root → Wallet endpoints: wires (evidence: `internal/config/app.go`)
- Composition root → Game endpoints: wires (evidence: `internal/config/app.go`)
- Composition root → Session endpoints: wires (evidence: `internal/config/app.go`)
- Composition root → Dashboard endpoint: wires (evidence: `internal/config/app.go`)
- Composition root → Account workflow: constructs (evidence: `internal/config/app.go`)
- Composition root → Wallet and top-ups: constructs (evidence: `internal/config/app.go`)
- Composition root → Catalog and ownership: constructs (evidence: `internal/config/app.go`)
- Composition root → Game sessions: constructs (evidence: `internal/config/app.go`)
- Composition root → Dashboard aggregation: constructs (evidence: `internal/config/app.go`)
- Account endpoints → Account workflow: invokes (evidence: `internal/delivery/http/controller/user_controller.go`)
- Wallet endpoints → Wallet and top-ups: invokes (evidence: `internal/delivery/http/controller/balance_controller.go`)
- Game endpoints → Catalog and ownership: invokes (evidence: `internal/delivery/http/controller/game_controller.go`)
- Session endpoints → Game sessions: invokes (evidence: `internal/delivery/http/controller/session_controller.go`)
- Game sessions → Game repository: checks ownership (evidence: `internal/usecase/session_usecase.go`)
- Game sessions → Session repository: checks and saves (evidence: `internal/usecase/session_usecase.go`)
- Game sessions → Game repository: updates playtime (evidence: `internal/usecase/session_usecase.go`)
- Session repository → PostgreSQL: reads and writes (evidence: `internal/repository/postgresql/session_repository.go`)
- Game repository → PostgreSQL: reads and writes (evidence: `internal/repository/postgresql/game_repository.go`)
- Composition root → User repository: constructs (evidence: `internal/config/app.go`)
- Composition root → Balance repository: constructs (evidence: `internal/config/app.go`)
- Composition root → Top-up repository: constructs (evidence: `internal/config/app.go`)
- Composition root → Game repository: constructs (evidence: `internal/config/app.go`)
- Composition root → Session repository: constructs (evidence: `internal/config/app.go`)
- Composition root → JWT service: constructs (evidence: `internal/config/app.go`)
- Composition root → Resend email: constructs (evidence: `internal/config/app.go`)
- Composition root → Xendit payments: constructs (evidence: `internal/config/app.go`)
- Composition root → ITAD catalog: constructs (evidence: `internal/config/app.go`)
