How xlstudi0/vybeo-backend works
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: app.module.ts App Module · events Events · payments Payments · tickets Tickets
Components 23
Platform Core
Bootstrapping, shared infrastructure, and cross-cutting runtime services.
- Bootstrap · Application startup, global pipes/guards, and server wiring.
src/main.ts - App Module · Top-level module that assembles the backend feature modules.
src/app.module.ts - Config · Environment loading, validation, and runtime settings.
src/config - Common · Shared helpers for request IDs, cache headers, scrubbing, throttling, cron locking, QR/TOTP, and exception handling.
src/common - Prisma · 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 · Login, registration, sessions, JWT, passkeys, 2FA, email verification, password recovery, and security reminders.
src/auth - Users · User lifecycle, profile updates, roles, phone OTP, and promoter application workflows.
src/users - Events · Event creation and updates, ticket types, categories, coordinates, featured status, and batch operations.
src/events - Tickets · Reservation, lookup, transfer, and cancellation workflows with explicit ticket state handling.
src/tickets - Payments · Checkout orchestration, idempotency, reservation locking, callbacks, queue tokens, and payment finalization.
src/payments - Azul · 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 · Staff assignment, offline scan bundles, scan sync, scanner gateway, and ticket scan logging.
src/event-staff - Presence · Live connection and presence gateway for operational realtime state.
src/presence - Signals · Live stats and operational signal aggregation for dashboards and monitoring.
src/signals - Notifications · Device tokens, push, SMS, and event reminder delivery surfaces.
src/notifications - Queue · Asynchronous email jobs and processors.
src/queue - Admin · Fraud review, transaction oversight, payout controls, observability views, and checkout bypass management.
src/admin - Promoter · Promoter-facing event and refund oversight workflows.
src/promoter - Audit · Queryable admin audit log and security-relevant action recording.
src/audit - Security · CSP report ingestion and surface-origin enforcement for protected mobile/admin surfaces.
src/security - Observability · OpenTelemetry, Sentry, request metrics, and Prometheus exposure.
src/observability - Webhooks · Webhook definitions, secrets, and delivery retention for external consumers.
src/webhooks - Wallet · Wallet-facing account surface for stored value or payout-related views.
src/wallet
Connections 25
- 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.