# avdyldemukajj/ticketapp architecture

> Architecture diagram of the GitHub repository avdyldemukajj/ticketapp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/avdyldemukajj/ticketapp
- Repository: https://github.com/avdyldemukajj/ticketapp

## Overview

##### Project type and purpose
- This is a full-stack, microservices-based ticketing/order management system.
- It consists of multiple Node.js services (auth, tickets, orders, payments, expiration), a React/Next.js client, event bus (NATS), databases, and Kubernetes deployment files.
- The system uses event-driven architecture for inter-service communication and integrates with Stripe for payment processing.

##### File structure
- Top-level directories
– auth, tickets, orders, payments, expiration: independent services
– client: Next.js frontend
– infra: Kubernetes manifests and ingress configuration
- Common patterns
– Each service has its own Dockerfile, tsconfig.json, src folder, tests, and package.json.
– Services publish and consume events via a shared NATS wrapper.
– Each service owns its own MongoDB collection (auth-mongo, tickets-mongo, orders-mongo, payments-mongo) and one uses Redis for delayed jobs.
- Deployment
– skaffold.yaml for development pipelines
– infra/k8s/*.yaml describes Deployments, Services, Redis, NATS, and Ingress.

##### Key insights from README
- The README isn’t descriptive; rely on file names and structure for system purpose.

##### Detail
- Flow of a typical user action end-to-end (e.g., user creates a ticket → event propagation → order creation → payment → expiration).
- Test and mock components if relevant, but keep focus on runtime architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Kubernetes Cluster Boundary
    subgraph "Kubernetes Cluster"
        style Kubernetes fill:#f9f,stroke:#333,stroke-width:2px
        Ingress["Ingress"]:::external
        ClientPod["Client Pod"]:::frontend
        AuthPod["Auth Service Pod"]:::backend
        TicketsPod["Tickets Service Pod"]:::backend
        OrdersPod["Orders Service Pod"]:::backend
        PaymentsPod["Payments Service Pod"]:::backend
        ExpirationPod["Expiration Service Pod"]:::backend
        NATSPod["NATS Pod"]:::event
    end

    %% Datastores
    AuthDB[(MongoDB<br/>auth-mongo)]:::db
    TicketsDB[(MongoDB<br/>tickets-mongo)]:::db
    OrdersDB[(MongoDB<br/>orders-mongo)]:::db
    PaymentsDB[(MongoDB<br/>payments-mongo)]:::db
    RedisDB[(Redis)]:::db

    %% External
    Stripe["Stripe API"]:::external
    Infra["Infra Manifests"]:::external
    Skaffold["Skaffold Pipeline"]:::external

    %% Client to Services via Ingress
    Ingress -->|routes to| ClientPod
    Ingress -->|routes to| AuthPod
    Ingress -->|routes to| TicketsPod
    Ingress -->|routes to| OrdersPod
    Ingress -->|routes to| PaymentsPod

    ClientPod -->|REST /api/auth| AuthPod
    ClientPod -->|REST /api/tickets| TicketsPod
    ClientPod -->|REST /api/orders| OrdersPod
    ClientPod -->|REST /api/payments| PaymentsPod

    %% Service to Database
    AuthPod -->|reads/writes| AuthDB
    TicketsPod -->|reads/writes| TicketsDB
    OrdersPod -->|reads/writes| OrdersDB
    PaymentsPod -->|reads/writes| PaymentsDB
    ExpirationPod -->|schedules jobs| RedisDB

    %% Event Bus
    AuthPod -->|publishes AuthEvents| NATSPod
    TicketsPod -->|publishes TicketCreated/Updated| NATSPod
    OrdersPod -->|publishes OrderCreated/Cancelled| NATSPod
    PaymentsPod -->|publishes PaymentCreated| NATSPod
    ExpirationPod -->|publishes ExpirationComplete| NATSPod

    NATSPod -->|subscribes| AuthPod
    NATSPod -->|subscribes| TicketsPod
    NATSPod -->|subscribes| OrdersPod
    NATSPod -->|subscribes| PaymentsPod
    NATSPod -->|subscribes| ExpirationPod

    %% Stripe integration
    PaymentsPod -->|calls Stripe API| Stripe
    Stripe -->|webhooks| PaymentsPod

    %% Infra & Skaffold
    Infra -.-> Kubernetes
    Skaffold -.-> Kubernetes

    %% Click Events
    click ClientPod "https://github.com/avdyldemukajj/ticketapp/tree/main/client/"
    click AuthPod "https://github.com/avdyldemukajj/ticketapp/blob/main/auth/src/index.ts"
    click TicketsPod "https://github.com/avdyldemukajj/ticketapp/blob/main/tickets/src/index.ts"
    click OrdersPod "https://github.com/avdyldemukajj/ticketapp/blob/main/orders/src/index.ts"
    click PaymentsPod "https://github.com/avdyldemukajj/ticketapp/blob/main/payments/src/index.ts"
    click ExpirationPod "https://github.com/avdyldemukajj/ticketapp/blob/main/expiration/src/index.ts"
    click NATSPod "https://github.com/avdyldemukajj/ticketapp/blob/main/tickets/src/nats-wrapper.ts"
    click Infra "https://github.com/avdyldemukajj/ticketapp/tree/main/infra/k8s/"
    click Skaffold "https://github.com/avdyldemukajj/ticketapp/blob/main/skaffold.yaml"

    %% Styles
    classDef frontend fill:#87CEFA,stroke:#333,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef event fill:#FFA500,stroke:#333,stroke-width:1px
    classDef db fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef external fill:#ffffff,stroke-dasharray: 5 5,stroke:#333,stroke-width:1px
```
