How hungryelderberry/nexus-video-games works
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: app.go Composition root · session_usecase.go Game sessions · game_repository.go Game repository · session_repository.go Session repository
Components 24
HTTP delivery
- Composition root
internal/config/app.go - Account endpoints
internal/delivery/http/controller/user_controller.go - Wallet endpoints
internal/delivery/http/controller/balance_controller.go - Game endpoints
internal/delivery/http/controller/game_controller.go - Session endpoints
internal/delivery/http/controller/session_controller.go - Dashboard endpoint
internal/delivery/http/controller/dashboard_controller.go - HTTP routing
internal/delivery/http/route/route.go
Business workflows
- Account workflow
internal/usecase/user_usecase.go - Wallet and top-ups
internal/usecase/balance_usecase.go - Catalog and ownership
internal/usecase/game_usecase.go - Game sessions
internal/usecase/session_usecase.go - Dashboard aggregation
internal/usecase/dashboard_usecase.go
Persistence
- PostgreSQL
- User repository
internal/repository/postgresql/user_repository.go - Balance repository
internal/repository/postgresql/balance_repository.go - Top-up repository
internal/repository/postgresql/topup_repository.go - Game repository
internal/repository/postgresql/game_repository.go - Session repository
internal/repository/postgresql/session_repository.go
External integrations
- Resend email
internal/gateway/email/resend_gateway.go - Xendit payments
internal/gateway/payment/xendit_gateway.go - ITAD catalog
internal/gateway/game/itad_gateway.go
Identity and security
- JWT middleware
internal/delivery/http/middleware/auth_middleware.go - JWT service
internal/pkg/jwt/jwt.go
Other components
- API client
Connections 30
- API client → HTTP routing: calls API
README.md - Composition root → HTTP routing: sets up
internal/config/app.go - Composition root → Account endpoints: wires
internal/config/app.go - Composition root → Wallet endpoints: wires
internal/config/app.go - Composition root → Game endpoints: wires
internal/config/app.go - Composition root → Session endpoints: wires
internal/config/app.go - Composition root → Dashboard endpoint: wires
internal/config/app.go - Composition root → Account workflow: constructs
internal/config/app.go - Composition root → Wallet and top-ups: constructs
internal/config/app.go - Composition root → Catalog and ownership: constructs
internal/config/app.go - Composition root → Game sessions: constructs
internal/config/app.go - Composition root → Dashboard aggregation: constructs
internal/config/app.go - Account endpoints → Account workflow: invokes
internal/delivery/http/controller/user_controller.go - Wallet endpoints → Wallet and top-ups: invokes
internal/delivery/http/controller/balance_controller.go - Game endpoints → Catalog and ownership: invokes
internal/delivery/http/controller/game_controller.go - Session endpoints → Game sessions: invokes
internal/delivery/http/controller/session_controller.go - Game sessions → Game repository: checks ownership
internal/usecase/session_usecase.go - Game sessions → Session repository: checks and saves
internal/usecase/session_usecase.go - Game sessions → Game repository: updates playtime
internal/usecase/session_usecase.go - Session repository → PostgreSQL: reads and writes
internal/repository/postgresql/session_repository.go - Game repository → PostgreSQL: reads and writes
internal/repository/postgresql/game_repository.go - Composition root → User repository: constructs
internal/config/app.go - Composition root → Balance repository: constructs
internal/config/app.go - Composition root → Top-up repository: constructs
internal/config/app.go - Composition root → Game repository: constructs
internal/config/app.go - Composition root → Session repository: constructs
internal/config/app.go - Composition root → JWT service: constructs
internal/config/app.go - Composition root → Resend email: constructs
internal/config/app.go - Composition root → Xendit payments: constructs
internal/config/app.go - Composition root → ITAD catalog: constructs
internal/config/app.go