# xlstudi0/vybeo-backend architecture

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

- Interactive diagram: https://gitdiagram.com/xlstudi0/vybeo-backend
- Repository: https://github.com/xlstudi0/vybeo-backend

## Overview

1. This is a single NestJS backend that acts as the core server for an event/ticketing platform. It exposes HTTP APIs, some WebSocket endpoints, background jobs, and several operational/admin surfaces. The code is organized as feature modules rather than separate services, but the domain is clearly decomposed.

2. The primary API boundary is the Nest controller/service layer. Requests enter through controllers, pass through DTO validation, guards, interceptors, and exception filters, then into domain services. Shared cross-cutting code lives under `src/common`, including caching headers, request IDs, log scrubbing, QR/TOTP helpers, cron locking, and throttling.

3. Authentication and authorization are a major subsystem. `src/auth` handles login, registration, password reset, email verification, JWT sessions, passkeys, 2FA, security reminders, and device fingerprinting. Access control is enforced by JWT guards, role decorators/guards, and “optional auth” paths for mixed public/private endpoints.

4. The data layer is Prisma-backed. `src/prisma` wraps the Prisma client, and the schema plus migrations define the persistent model for users, events, tickets, payments, audits, device tokens, waitlists, scan logs, and security/audit state. The repository is migration-heavy, which indicates the schema is a central architectural boundary.

5. Payments are one of the most complex domains. `src/payments` contains a provider abstraction plus a concrete Azul implementation under `src/payments/providers/azul`. The payment flow includes checkout session creation, idempotency, reservation locking, callback handling, ticket issuance, queue tokens, and saved payment methods via a “datavault” path. The README’s idempotency note reflects that payment creation must be safe against retries and double reservation.

6. Ticketing is split into reservation, lookup, transfer, and cancellation flows under `src/tickets`. Ticket inventory is reserved before or during payment, then finalized into issued tickets. Cancellations and transfers are separate workflows, suggesting explicit state transitions and auditability rather than a simple CRUD model.

7. Event management is its own bounded context in `src/events`, with categories and event-specific DTOs for creation, updates, ticket types, coordinates, featured status, and batch operations. The docs also indicate support for queues, mobile event mode, and event-specific operational rules, so the event entity drives downstream behavior in payments, staffing, signals, and waitlists.

8. Staff-facing operations are handled by `src/event-staff`. This module combines event staff assignment, offline scan bundles, scan synchronization, a scanner gateway, and ticket scan logging. The presence of a gateway and offline sync services suggests a real-time/mobile workflow where scanners can work disconnected and later reconcile with the server.

9. Real-time and presence features are split into dedicated modules. `src/presence` provides a gateway for live presence/connection state, while `src/signals` exposes live stats/operational signals. These appear to feed live dashboards and event operations rather than customer-facing functionality.

10. Notifications and messaging are asynchronous and multi-channel. `src/queue` manages email jobs, while `src/mail`, `src/notifications`, and `src/waitlist` handle email, push tokens, SMS, event reminders, and waitlist notifications. Redis is used for queueing/infrastructure support, and the system separates message generation from delivery.

11. Admin, promoter, and audit capabilities are first-class modules. `src/admin`, `src/promoter`, and `src/audit` support fraud review, transaction oversight, payout management, checkout bypass controls, and queryable audit logs. This makes the backend not just transactional, but also operationally supervised.

12. Security hardening is built into the architecture. `src/security` contains CSP report ingestion and surface-origin enforcement, while the docs and CI mention secrets scanning, preflight checks, and production readiness. The repo also includes `gitleaks`, env validation, and deploy guards, so security is enforced both at runtime and in the delivery pipeline.

13. Observability is explicitly integrated. `src/observability` boots OpenTelemetry and Sentry, exposes Prometheus metrics, and records request metrics. There is also a health module, which means the service is designed for monitoring, alerting, and production operations from the start.

14. External integrations are concentrated behind service modules: Azul for payments, mail for email delivery, SMS/push for notifications, and webhooks for outbound event delivery. `src/webhooks` manages webhook definitions, secrets, and delivery retention, which suggests the backend can publish domain events to external consumers.

15. Operationally, the repo is packaged for containerized deployment and CI/CD. Docker files, compose files, GitHub Actions workflows, load tests, and deployment scripts indicate a production system with automated checks, release guards, and benchmarking. OpenAPI generation is also present, so the API contract is part of the build/release process.

Main entry points: [`src/app.module.ts`](https://github.com/xlstudi0/vybeo-backend/blob/main/src/app.module.ts) (App Module), [`src/events`](https://github.com/xlstudi0/vybeo-backend/tree/main/src/events) (Events), [`src/payments`](https://github.com/xlstudi0/vybeo-backend/tree/main/src/payments) (Payments), [`src/tickets`](https://github.com/xlstudi0/vybeo-backend/tree/main/src/tickets) (Tickets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_platform["Platform Core"]
  node_main["Bootstrap<br/>Nest entrypoint<br/>[main.ts]"]
  node_app_module["App Module<br/>Nest composition<br/>[app.module.ts]"]
  node_config["Config"]
  node_common["Common<br/>cross-cutting"]
  node_prisma[("Prisma<br/>data access")]
end

subgraph group_domains["Domain Modules"]
  node_auth["Auth<br/>identity"]
  node_users["Users<br/>user profile"]
  node_events["Events<br/>event catalog"]
  node_tickets["Tickets<br/>ticketing"]
  node_payments["Payments<br/>checkout"]
  node_azul["Azul<br/>provider adapter"]
end

subgraph group_ops["Operations"]
  node_staff["Event Staff<br/>ops workflow"]
  node_presence(("Presence<br/>realtime"))
  node_signals(("Signals<br/>live ops"))
  node_notifications["Notifications<br/>messaging"]
  node_queue["Queue<br/>jobs"]
  node_admin["Admin<br/>supervision"]
  node_promoter["Promoter<br/>partner ops"]
  node_audit["Audit"]
  node_security["Security<br/>hardening"]
  node_observability["Observability<br/>telemetry"]
  node_webhooks["Webhooks<br/>outbound delivery"]
  node_wallet["Wallet<br/>accounting"]
end

node_main -->|"boots"| node_app_module
node_app_module -->|"loads"| node_config
node_app_module -->|"shares"| node_common
node_app_module -->|"persists"| node_prisma
node_app_module -->|"authenticates"| node_auth
node_app_module -->|"manages"| node_users
node_app_module -->|"hosts"| node_events
node_app_module -->|"issues"| node_tickets
node_app_module -->|"charges"| node_payments
node_payments -->|"uses"| node_azul
node_payments -->|"finalizes"| node_tickets
node_events -->|"drives"| node_tickets
node_events -->|"enables"| node_staff
node_app_module -->|"operates"| node_staff
node_app_module -->|"streams"| node_presence
node_app_module -->|"reports"| node_signals
node_app_module -->|"notifies"| node_notifications
node_notifications -->|"enqueues"| node_queue
node_app_module -->|"supervises"| node_admin
node_admin -->|"records"| node_audit
node_app_module -->|"partners"| node_promoter
node_app_module -->|"hardens"| node_security
node_app_module -->|"observes"| node_observability
node_app_module -->|"publishes"| node_webhooks
node_app_module -->|"supports"| node_wallet

click node_main "https://github.com/xlstudi0/vybeo-backend/blob/main/src/main.ts"
click node_app_module "https://github.com/xlstudi0/vybeo-backend/blob/main/src/app.module.ts"
click node_config "https://github.com/xlstudi0/vybeo-backend/tree/main/src/config"
click node_common "https://github.com/xlstudi0/vybeo-backend/tree/main/src/common"
click node_prisma "https://github.com/xlstudi0/vybeo-backend/tree/main/src/prisma"
click node_auth "https://github.com/xlstudi0/vybeo-backend/tree/main/src/auth"
click node_users "https://github.com/xlstudi0/vybeo-backend/tree/main/src/users"
click node_events "https://github.com/xlstudi0/vybeo-backend/tree/main/src/events"
click node_tickets "https://github.com/xlstudi0/vybeo-backend/tree/main/src/tickets"
click node_payments "https://github.com/xlstudi0/vybeo-backend/tree/main/src/payments"
click node_azul "https://github.com/xlstudi0/vybeo-backend/tree/main/src/payments/providers/azul"
click node_staff "https://github.com/xlstudi0/vybeo-backend/tree/main/src/event-staff"
click node_presence "https://github.com/xlstudi0/vybeo-backend/tree/main/src/presence"
click node_signals "https://github.com/xlstudi0/vybeo-backend/tree/main/src/signals"
click node_notifications "https://github.com/xlstudi0/vybeo-backend/tree/main/src/notifications"
click node_queue "https://github.com/xlstudi0/vybeo-backend/tree/main/src/queue"
click node_admin "https://github.com/xlstudi0/vybeo-backend/tree/main/src/admin"
click node_promoter "https://github.com/xlstudi0/vybeo-backend/tree/main/src/promoter"
click node_audit "https://github.com/xlstudi0/vybeo-backend/tree/main/src/audit"
click node_security "https://github.com/xlstudi0/vybeo-backend/tree/main/src/security"
click node_observability "https://github.com/xlstudi0/vybeo-backend/tree/main/src/observability"
click node_webhooks "https://github.com/xlstudi0/vybeo-backend/tree/main/src/webhooks"
click node_wallet "https://github.com/xlstudi0/vybeo-backend/tree/main/src/wallet"

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_main,node_app_module,node_config,node_common,node_prisma toneBlue
class node_auth,node_users,node_events,node_tickets,node_payments,node_azul toneAmber
class node_staff,node_presence,node_signals,node_notifications,node_queue,node_admin,node_promoter,node_audit,node_security,node_observability,node_webhooks,node_wallet toneMint
```

## Components

### Platform Core

Bootstrapping, shared infrastructure, and cross-cutting runtime services.

- [Bootstrap](https://github.com/xlstudi0/vybeo-backend/blob/main/src/main.ts): Nest entrypoint · Application startup, global pipes/guards, and server wiring. · `src/main.ts`
- [App Module](https://github.com/xlstudi0/vybeo-backend/blob/main/src/app.module.ts): Nest composition · Top-level module that assembles the backend feature modules. · `src/app.module.ts`
- [Config](https://github.com/xlstudi0/vybeo-backend/tree/main/src/config): env/config · Environment loading, validation, and runtime settings. · `src/config`
- [Common](https://github.com/xlstudi0/vybeo-backend/tree/main/src/common): cross-cutting · Shared helpers for request IDs, cache headers, scrubbing, throttling, cron locking, QR/TOTP, and exception handling. · `src/common`
- [Prisma](https://github.com/xlstudi0/vybeo-backend/tree/main/src/prisma): data access · Prisma client wrapper and persistence boundary for the database schema and migrations. · `src/prisma`

### Domain Modules

Primary business boundaries for identity, events, payments, tickets, and users.

- [Auth](https://github.com/xlstudi0/vybeo-backend/tree/main/src/auth): identity · Login, registration, sessions, JWT, passkeys, 2FA, email verification, password recovery, and security reminders. · `src/auth`
- [Users](https://github.com/xlstudi0/vybeo-backend/tree/main/src/users): user profile · User lifecycle, profile updates, roles, phone OTP, and promoter application workflows. · `src/users`
- [Events](https://github.com/xlstudi0/vybeo-backend/tree/main/src/events): event catalog · Event creation and updates, ticket types, categories, coordinates, featured status, and batch operations. · `src/events`
- [Tickets](https://github.com/xlstudi0/vybeo-backend/tree/main/src/tickets): ticketing · Reservation, lookup, transfer, and cancellation workflows with explicit ticket state handling. · `src/tickets`
- [Payments](https://github.com/xlstudi0/vybeo-backend/tree/main/src/payments): checkout · Checkout orchestration, idempotency, reservation locking, callbacks, queue tokens, and payment finalization. · `src/payments`
- [Azul](https://github.com/xlstudi0/vybeo-backend/tree/main/src/payments/providers/azul): provider adapter · Concrete payment provider integration, webservices client, signing, redirect page, and PAN feature guard. · `src/payments/providers/azul`

### Operations

Staff, admin, notifications, observability, security, and external delivery surfaces.

- [Event Staff](https://github.com/xlstudi0/vybeo-backend/tree/main/src/event-staff): ops workflow · Staff assignment, offline scan bundles, scan sync, scanner gateway, and ticket scan logging. · `src/event-staff`
- [Presence](https://github.com/xlstudi0/vybeo-backend/tree/main/src/presence): realtime · Live connection and presence gateway for operational realtime state. · `src/presence`
- [Signals](https://github.com/xlstudi0/vybeo-backend/tree/main/src/signals): live ops · Live stats and operational signal aggregation for dashboards and monitoring. · `src/signals`
- [Notifications](https://github.com/xlstudi0/vybeo-backend/tree/main/src/notifications): messaging · Device tokens, push, SMS, and event reminder delivery surfaces. · `src/notifications`
- [Queue](https://github.com/xlstudi0/vybeo-backend/tree/main/src/queue): jobs · Asynchronous email jobs and processors. · `src/queue`
- [Admin](https://github.com/xlstudi0/vybeo-backend/tree/main/src/admin): supervision · Fraud review, transaction oversight, payout controls, observability views, and checkout bypass management. · `src/admin`
- [Promoter](https://github.com/xlstudi0/vybeo-backend/tree/main/src/promoter): partner ops · Promoter-facing event and refund oversight workflows. · `src/promoter`
- [Audit](https://github.com/xlstudi0/vybeo-backend/tree/main/src/audit): audit log · Queryable admin audit log and security-relevant action recording. · `src/audit`
- [Security](https://github.com/xlstudi0/vybeo-backend/tree/main/src/security): hardening · CSP report ingestion and surface-origin enforcement for protected mobile/admin surfaces. · `src/security`
- [Observability](https://github.com/xlstudi0/vybeo-backend/tree/main/src/observability): telemetry · OpenTelemetry, Sentry, request metrics, and Prometheus exposure. · `src/observability`
- [Webhooks](https://github.com/xlstudi0/vybeo-backend/tree/main/src/webhooks): outbound delivery · Webhook definitions, secrets, and delivery retention for external consumers. · `src/webhooks`
- [Wallet](https://github.com/xlstudi0/vybeo-backend/tree/main/src/wallet): accounting · Wallet-facing account surface for stored value or payout-related views. · `src/wallet`

## Connections

- Bootstrap → App Module: boots · Entrypoint initializes the application module.
- App Module → Config: loads · Core module depends on validated runtime configuration.
- App Module → Common: shares · Global guards, interceptors, filters, and helpers are reused across modules.
- App Module → Prisma: persists · All business modules use the Prisma-backed persistence layer.
- App Module → Auth: authenticates · Identity and session boundaries are attached to the app.
- App Module → Users: manages · User and promoter profile workflows are exposed as a major domain.
- App Module → Events: hosts · Event catalog and operational event rules are core to the backend.
- App Module → Tickets: issues · Ticket lifecycle services are part of the main domain model.
- App Module → Payments: charges · Checkout and payment orchestration are central APIs.
- Payments → Azul: uses · Payments route provider-specific behavior through Azul integration.
- Payments → Tickets: finalizes · Successful checkout finalizes reserved inventory into issued tickets.
- Events → Tickets: drives · Event configuration determines ticket types and inventory behavior.
- Events → Event Staff: enables · Event setup feeds staffing, scanning, and offline check-in operations.
- App Module → Event Staff: operates · Staff operations are exposed as a first-class surface.
- App Module → Presence: streams · Realtime presence is provided as a dedicated operational gateway.
- App Module → Signals: reports · Live operational metrics and signals are exposed separately.
- App Module → Notifications: notifies · Async email, push, SMS, and reminders are coordinated here.
- Notifications → Queue: enqueues · Message work is processed asynchronously through queue jobs.
- App Module → Admin: supervises · Admin workflows provide fraud, payout, and checkout controls.
- Admin → Audit: records · Administrative actions are captured in the audit log boundary.
- App Module → Promoter: partners · Promoter-specific oversight is separated from general admin.
- App Module → Security: hardens · Security reports and surface protections are exposed at the app level.
- App Module → Observability: observes · Telemetry and request metrics are installed globally.
- App Module → Webhooks: publishes · Outbound webhook delivery is a dedicated integration surface.
- App Module → Wallet: supports · Wallet/accounting-related views are included as a separate surface.
