# fiqrioemry/event-ticketing-system-application architecture

> Architecture diagram of the GitHub repository fiqrioemry/event-ticketing-system-application, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fiqrioemry/event-ticketing-system-application
- Repository: https://github.com/fiqrioemry/event-ticketing-system-application

## Overview

##### Project Type and Purpose
- Tiketku is a full-stack event ticketing system.
- Frontend: a SvelteKit-based single-page application for users and admin dashboards.
- Backend: a Golang (Gin) REST API that handles authentication, event/ticket CRUD, orders, refunds, withdrawals, reporting.
- External integrations: Stripe (payments/webhooks), Redis (OTP & token store), Cloudinary (asset upload), SMTP (Nodemailer), MySQL (GORM), API key validation.

##### File Structure
- Top-level directories:
- client/ – frontend SvelteKit code
- server/ – backend Go service
- docs/ – Postman collection
- Frontend breaks down into API clients, stores, services/hooks, UI components, routes.
- Backend follows a layered pattern:
- config/ – bootstrap of DB, Redis, Stripe, etc.
- dto/ – request/response schemas
- handlers/ (controllers) → services/ (business logic) → repositories/ (DB access) → models/
- middleware/ – auth, CORS, rate limiting, error recovery
- cron/ – scheduled tasks
- utils/ – helpers (logging, JWT, hashing, emailing)
- Deployment artifacts: Dockerfiles, docker-compose.yml, GitHub Actions.

##### Extract Key Architectural Insights from README
- JWT-based auth with Access/Refresh tokens and Google OAuth.
- Role-based API access (User vs Admin).
- Stripe Checkout for payments and webhooks for asynchronous events.
- Cron jobs for reminders, auto-expire payments.
- CSV export for reporting.
- Partial refund flow and user wallet/withdrawal workflow.

a. Main Components
1. Frontend SPA (SvelteKit + TailwindCSS + TanStack Query + Zod)
2. API Gateway (Gin router + middleware)
3. Business Layer (services)
4. Data Access Layer (GORM → MySQL)
5. Redis Cache/Store (OTP, token blacklists)
6. External Services:
– Stripe (Checkout, Webhooks)
– Cloudinary (Asset uploads)
– SMTP Server (Nodemailer)
7. Cron Scheduler (scheduled jobs)
8. File store / static hosting (Netlify or Hostinger)

b. Relationships & Interactions
- User/admin browser ↔ Frontend (SvelteKit routes/UI components)
- Frontend ↔ Backend REST API (/api/v1/*) via fetch/axios
- Backend middleware authenticates JWT or API key
- Handlers invoke services → repositories → MySQL
- Services call Redis for OTP/token operations
- Payment flow:
– Frontend triggers Stripe Checkout
– Stripe redirects and posts webhooks → /payments/stripe/webhooks
– Backend updates order/payment status
- Refund flow:
– Admin POST /orders/:id/refund → service adjusts wallet → issues partial refund via Stripe API
- Withdrawal:
– User POST /withdrawals → service validates, writes to DB
- Reporting:
– Admin GET /reports/transaction → service queries DB → optionally exports CSV

c. Architectural Patterns & Principles
- Layered (Controller → Service → Repository → Model)
- Separation of concerns (auth, business logic, data access in separate packages)
- Hexagonal touches: external adapters (Stripe, Redis) isolated in utils or config
- Event-driven for webhooks & cron jobs
- Role-based access control via middleware

d. Key Technologies & Frameworks
- Frontend: SvelteKit, TailwindCSS, @tanstack/svelte-query, Zod, Vite
- Backend: Go, Gin, GORM(MySQL), Redis, Stripe SDK, JWT, Cloudinary SDK, Nodemailer
- Orchestration: Docker, Docker-Compose, GitHub Actions CI/CD

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Application Layer
    Browser["User/Admin Browser"]:::external
    SPAS["Frontend SPA"]:::frontend

    %% Frontend Components
    APIClient["API Clients (client/src/lib/api/client.ts)"]:::frontend
    ServicesFE["Frontend Services (client/src/lib/services/*.ts)"]:::frontend
    StoresHooks["Stores & Hooks (client/src/lib/stores/*.ts, client/src/lib/hooks/*.ts)"]:::frontend
    UIComponents["UI Components & Routes (client/src/lib/components/, client/src/routes/)"]:::frontend

    %% API Layer
    API["API Gateway<br/>(Gin Router + Middleware)"]:::backend

    %% Authentication Middleware
    Auth["Authentication Middleware<br/>(JWT, Google OAuth, RBAC)"]:::backend

    %% Controllers & Business Layers
    Handlers["Controllers / Handlers"]:::backend
    ServicesBL["Business Layer (Services)"]:::backend
    Repos["Data Access Layer<br/>(Repositories)"]:::backend
    Models["Data Models (GORM)"]:::backend

    %% Data Layer
    DB["MySQL (GORM)"]:::db
    RedisUtil["Redis Cache/Store"]:::backend

    %% External Integrations
    StripeCheck["Stripe Checkout"]:::external
    StripeWebhook["Stripe Webhooks"]:::external
    StripeInt["Stripe Integration<br/>(server/config/stripe.go, payment_service)"]:::backend
    CloudinaryInt["Cloudinary Asset Upload"]:::external
    SMTPInt["SMTP Emailing"]:::external

    %% Cron & Utilities
    CronSched["Cron Scheduler"]:::backend
    Utils["Utilities<br/>(Logging, Hashing, Validation, CSV Export)"]:::backend
    Seeders["Seeders (server/seeders/)"]:::backend

    %% Deployment
    Deployment["Deployment & Orchestration"]:::external

    %% Relationships
    Browser -->|"HTTPS REST"| SPAS
    SPAS -->|"REST /api/v1/*"| API
    SPAS -.->|"Trigger Checkout"| StripeCheck
    StripeCheck -->|"Redirect & Payment"| SPAS
    StripeWebhook -->|"POST /payments/stripe/webhooks"| API

    API -->|uses middleware| Auth
    API -->|"Controller Invocation"| Handlers

    Handlers -->|"calls"| ServicesBL
    ServicesBL -->|"queries"| Repos
    Repos -->|"maps to"| Models
    Models -->|"persists"| DB

    ServicesBL -->|"cache/token ops"| RedisUtil
    ServicesBL -->|"calls"| StripeInt
    ServicesBL -->|"uploads"| CloudinaryInt
    ServicesBL -->|"emails via"| SMTPInt
    CronSched -->|"scheduled jobs"| ServicesBL
    Handlers -->|"utils"| Utils

    %% Frontend internal flows
    SPAS --> APIClient
    SPAS --> ServicesFE
    SPAS --> StoresHooks
    SPAS --> UIComponents

    %% Deployment flows
    SPAS --> Deployment
    API --> Deployment
    DB --> Deployment
    RedisUtil --> Deployment

    %% Click Events - Frontend
    click SPAS "https://github.com/fiqrioemry/event-ticketing-system-application/tree/main/client/"
    click APIClient "https://github.com/fiqrioemry/event-ticketing-system-application/blob/main/client/src/lib/api/client.ts"
    click ServicesFE "https://github.com/fiqrioemry/event-ticketing-system-application/blob/main/client/src/lib/services/*.ts"
    click StoresHooks "https://github.com/fiqrioemry/event-ticketing-system-application/blob/main/client/src/lib/stores/*.ts"
    click StoresHooks "https://github.com/fiqrioemry/event-ticketing-system-application/blob/main/client/src/lib/hooks/*.ts"
    click UIComponents "https://github.com/fiqrioemry/event-ticketing-system-application/tree/main/client/src/lib/components/"
    click UIComponents "https://github.com/fiqrioemry/event-ticketing-system-application/tree/main/client/src/routes/"

    %% Click Events - Backend
    click API "https://github.com/fiqrioemry/event-ticketing-system-application/blob/main/server/main.go"
    click Auth "https://github.com/fiqrioemry/event-ticketing-system-application/blob/main/server/utils/jwt.go"
    click Handlers "https://github.com/fiqrioemry/event-ticketing-system-application/tree/main/server/handlers/"
    click ServicesBL "https://github.com/fiqrioemry/event-ticketing-system-application/blob/main/server/services/*.go"
    click Repos "https://github.com/fiqrioemry/event-ticketing-system-application/blob/main/server/repositories/*.go"
    click Models "https://github.com/fiqrioemry/event-ticketing-system-application/blob/main/server/models/model.go"
    click DB "https://github.com/fiqrioemry/event-ticketing-system-application/blob/main/server/config/*.go"
    click RedisUtil "https://github.com/fiqrioemry/event-ticketing-system-application/blob/main/server/utils/cache.go"
    click StripeInt "https://github.com/fiqrioemry/event-ticketing-system-application/blob/main/server/config/stripe.go"
    click CloudinaryInt "https://github.com/fiqrioemry/event-ticketing-system-application/blob/main/server/config/cloudinary.go"
    click SMTPInt "https://github.com/fiqrioemry/event-ticketing-system-application/blob/main/server/config/nodemailer.go"
    click CronSched "https://github.com/fiqrioemry/event-ticketing-system-application/blob/main/server/cron/cron_manager.go"
    click Utils "https://github.com/fiqrioemry/event-ticketing-system-application/blob/main/server/utils/export.go"
    click Seeders "https://github.com/fiqrioemry/event-ticketing-system-application/tree/main/server/seeders/"
    click Deployment "https://github.com/fiqrioemry/event-ticketing-system-application/blob/main/server/docker-compose.yml"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
    classDef db fill:#FFFF99,stroke:#333,stroke-width:1px,shape:cylinder
```
