# sai-deekshith-06/playo architecture

> Architecture diagram of the GitHub repository sai-deekshith-06/playo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-03-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sai-deekshith-06/playo
- Repository: https://github.com/sai-deekshith-06/playo

## Overview

##### What this project is (type + purpose)
This repo is a **full-stack, microservices-based web application**:

- **Frontend**: `frontend/` is a **React + Vite** SPA (Tailwind present via `tailwind.config.js`), with pages for booking, playing, trainers, and player profile flows.
- **Backend**: `services/` is a **Spring Boot / Spring Cloud** microservices setup orchestrated by **Docker Compose**, with:
- **API Gateway** (`services/api-gateway`) — Spring Cloud Gateway routing + CORS.
- **Service Discovery** (`services/eureka-server`) — Netflix Eureka.
- **Auth/User service** (`services/auth-server`) — JWT security, registration/login, profile update, Cloudinary image upload, persistence via Postgres, and Redis likely for caching/session/other (per README ports).

Purpose, from structure: a “Sportify”-like platform enabling users to browse sports offerings (games/venues/coaching/events/memberships), book things, and manage user profile/authentication, with a gateway + discovery.

##### Frontend (`frontend/`)
Key architectural hints:
- `src/Pages/...` indicates a **page-driven SPA**. Major domains:
- `Pages/book/*` (venues, events, coaching, memberships)
- `Pages/play/*` (games browsing/filtering)
- `Pages/player/*` (profile, bookings, feedback)
- `Pages/trainer/*` (trainers listing/search)
- `src/api/axios.js` suggests a single HTTP client wrapper (likely baseURL to gateway + interceptors for JWT).
- `src/utils/userContext.jsx` suggests **client-side auth state** (context provider for user/session).

##### Backend (`services/`)
- `docker-compose.yml` is the orchestration truth: this is where Postgres/Redis and the Spring services are wired.
- **Eureka pattern**: services register with Eureka; the API Gateway routes to services by logical name.
- `auth-server/security/*` and `SecurityConfig.java` clearly show **JWT-based auth**.
- `auth-server/config/CloudinaryConfig.java` + `service/UploadImage.java` means an external dependency: **Cloudinary**.
- `auth-server/repository/UserRepository.java` + `entity/User.java` means **PostgreSQL as source of truth** for users.
- README calls out **Redis**; not shown in code usage from tree alone, but it’s part of deployed architecture and should be diagrammed (possibly used by auth service or future services).

##### Context / System Landscape (Level 1)
Goal: show the product boundary and external dependencies.

Include:
- End User (Browser)
- Your System: “Sportify Web App”
- External services: Cloudinary
- (Optional) “Future/Other microservices” as a placeholder since Eureka/Gateway suggests expansion

Goal: capture deployable units and runtime communication.

- **Browser**
- **Frontend SPA (React/Vite)** — served separately (local dev via Vite; production could be static hosting)
- **API Gateway (Spring Cloud Gateway, :8040)**
- **Eureka Server (:8761)**
- **Auth Server (Spring Boot)**
- **PostgreSQL (:5432)**
- **Redis (:6379)**
- **Cloudinary (external)**

##### Auth Server → Cloudinary (upload/profile image hosting)
9. API Gateway → Frontend? (usually no; keep it separate unless gateway serves static assets, which isn’t implied here)

**Also annotate cross-cutting concerns:**
- JWT validation location: either at **gateway**, **auth-server**, or both. Given `auth-server/security/JwtAuthenticationFilter.java`, auth server validates JWT for its endpoints; gateway may just forward (unless configured otherwise—route config file might show filters).

Goal: represent internal structure of the most substantial service (`auth-server`).

- Controllers:
- `AuthController` (login/register endpoints)
- `UpdateProfileController`
- Security:
- `SecurityConfig`
- `JwtAuthenticationFilter`
- `JwtService`
- `CustomUserDetailsService`
- `CustomUserPrincipal`
- Data layer:
- `UserRepository`
- Entities: `User`, `Role`
- Integration:
- `UploadImage` → Cloudinary
- DTO boundary:
- `AuthRequest`, `RegisterRequest`, `AuthResponse`, `ErrorResponse`
- Error handling:
- `GlobalExceptionHandler`

- Controllers → Services/Security → Repository → Postgres
- Profile update flow → UploadImage → Cloudinary
- Security filter → JwtService/UserDetailsService → Repository

##### What to include as labels (technologies + ports + protocols)
- Frontend: React, Vite, Tailwind, Axios
- Gateway: Spring Boot, Spring Cloud Gateway, CORS, routes config
- Discovery: Netflix Eureka
- Auth: Spring Boot, Spring Security, JWT, Cloudinary integration, Spring Data JPA
- Data: PostgreSQL, Redis
- Orchestration: Docker Compose

- Gateway `:8040`
- Eureka `:8761`
- Postgres `:5432`
- Redis `:6379`

- “HTTPS/REST + JWT”
- “Service registration”
- “Service discovery”
- “JDBC/JPA”
- “Redis protocol”
- “Cloudinary API”

##### Concrete “component separation” checklist (don’t overthink; split aggressively)

- SPA
- Gateway
- Eureka
- Auth service
- Postgres
- Redis
- Cloudinary

- Controller layer
- Security/JWT filter layer
- Service layer (UploadImage, JwtService, UserDetails)
- Repository/entities
- External integration (Cloudinary)
- Data stores

- `GatewayRouteConfig` (routes → auth-server)
- `CorsConfig`
- `HealthController`
- Any filters (if present later)

##### (Optional) Request flow sequence: Login + Authenticated Profile Update
- Browser → SPA → Gateway → Auth Controller → Postgres
- SPA stores JWT via context → subsequent request with Authorization header
- Profile update includes image upload → Cloudinary

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% =========================
  %% DIAGRAM 1: SYSTEM CONTEXT (C4 L1)
  %% =========================
  subgraph "System Context (Level 1)"
    direction TB

    U["End User<br/>(Browser)"]:::external

    subgraph "Sportify Web App"
      direction TB
      SYS["Sportify Platform"]:::system
    end

    CLD["Cloudinary<br/>(External Image Hosting)"]:::external
    FUT["Future/Other Microservices<br/>(placeholder)"]:::future

    U -->|"Uses"| SYS
    SYS -->|"UploadsProfileImages"| CLD
    SYS -.->|"DesignedForExpansion"| FUT
  end

  %% =========================
  %% DIAGRAM 2: CONTAINERS / DEPLOYMENT (C4 L2)
  %% =========================
  subgraph "Container / Deployment (Level 2)"
    direction TB

    B["Browser"]:::client

    FE["Frontend SPA<br/>(React + Vite + Tailwind + Axios)"]:::frontend
    FE_DOM["UI Domains<br/>- Book (venues/events/coaching/memberships)<br/>- Play (games/filtering)<br/>- Trainer (listing/search)<br/>- Player (profile/bookings/feedback)<br/><i>Note:</i> Some pages use local mock data modules today"]:::note

    B -->|"HTTP(S)"| FE
    FE -->|"Renders"| FE_DOM

    subgraph "Docker Compose Boundary (services/)" 
      direction TB

      DC["Orchestration<br/>(docker-compose.yml)"]:::infra

      GW["API Gateway<br/>(Spring Cloud Gateway)<br/>:8040"]:::backend
      GW_R["Routing Rules<br/>(GatewayRouteConfig)"]:::backend2
      GW_C["CORS Config<br/>(CorsConfig)"]:::backend2
      GW_H["Health Endpoint<br/>(HealthController)"]:::backend2

      EU["Service Discovery<br/>(Netflix Eureka)<br/>:8761"]:::backend

      AU["Auth/User Service<br/>(Spring Boot + Spring Security + JWT)"]:::backend

      PG[("PostgreSQL<br/>:5432")]:::datastore
      RD[("Redis<br/>:6379")]:::datastore

      CLD2["Cloudinary<br/>(External)"]:::external

      DC --- GW
      DC --- EU
      DC --- AU
      DC --- PG
      DC --- RD

      GW -->|"Hosts"| GW_R
      GW -->|"Hosts"| GW_C
      GW -->|"Hosts"| GW_H

      %% Runtime flows
      FE -->|"REST/HTTP+JWT<br/>(Authorization header)"| GW
      GW -->|"RoutesTo(auth-server)"| AU

      %% Control-plane (dashed)
      GW -.->|"ServiceDiscoveryLookup"| EU
      AU -.->|"ServiceRegistration"| EU

      %% Data/integrations
      AU -->|"JPA/JDBC CRUD"| PG
      AU -->|"RedisProtocol<br/>(cache/session/token store - per compose)"| RD
      AU -->|"Cloudinary API"| CLD2
    end
  end

  %% =========================
  %% DIAGRAM 3: AUTH SERVER COMPONENTS (C4 L3)
  %% =========================
  subgraph "Auth Server Internals (Level 3)"
    direction TB

    AU3["Auth/User Service<br/>(Spring Boot)"]:::backend

    subgraph "Controller Layer"
      direction TB
      AC["AuthController<br/>(login/register)"]:::component
      UPC["UpdateProfileController"]:::component
    end

    subgraph "Security Layer (JWT)"
      direction TB
      SC["SecurityConfig"]:::security
      JF["JwtAuthenticationFilter"]:::security
      JS["JwtService"]:::security
      CUDS["CustomUserDetailsService"]:::security
      CUP["CustomUserPrincipal"]:::security
    end

    subgraph "Application/Integration Services"
      direction TB
      CIC["CloudinaryConfig"]:::component
      UI["UploadImage<br/>(Cloudinary client wrapper)"]:::component
    end

    subgraph "DTO Boundary"
      direction TB
      DTO["DTOs<br/>(AuthRequest/RegisterRequest/AuthResponse/ErrorResponse)"]:::component
    end

    subgraph "Persistence Layer"
      direction TB
      UR["UserRepository"]:::component
      UENT["User Entity"]:::component
      RENT["Role Entity"]:::component
      PG3[("PostgreSQL")]:::datastore
    end

    subgraph "Error Handling"
      direction TB
      GEH["GlobalExceptionHandler"]:::component
    end

    CLD3["Cloudinary<br/>(External)"]:::external
    RD3[("Redis")]:::datastore

    %% Wiring inside service
    AU3 -->|"Exposes"| AC
    AU3 -->|"Exposes"| UPC

    AC -->|"Uses"| DTO
    UPC -->|"Uses"| DTO

    AC -->|"ProtectedBy"| SC
    UPC -->|"ProtectedBy"| SC

    SC -->|"Installs"| JF
    JF -->|"ValidatesToken"| JS
    JF -->|"LoadsUser"| CUDS
    CUDS -->|"Builds"| CUP

    CUDS -->|"Reads"| UR
    UR -->|"MapsTo"| UENT
    UENT -->|"Has"| RENT
    UR -->|"JPA/JDBC"| PG3

    UPC -->|"UploadsAvatar"| UI
    CIC -->|"Configures"| UI
    UI -->|"Cloudinary API"| CLD3

    AU3 -.->|"MayUse(per compose)"| RD3

    AC -->|"Throws/HandledBy"| GEH
    UPC -->|"Throws/HandledBy"| GEH
  end

  %% =========================
  %% CLICK EVENTS (from component_mapping)
  %% =========================
  click FE "https://github.com/sai-deekshith-06/playo/tree/main/frontend/"
  click FE "https://github.com/sai-deekshith-06/playo/tree/main/frontend/"
  click DC "https://github.com/sai-deekshith-06/playo/blob/main/services/docker-compose.yml"

  click GW "https://github.com/sai-deekshith-06/playo/tree/main/services/api-gateway/"
  click GW_R "https://github.com/sai-deekshith-06/playo/blob/main/services/api-gateway/src/main/java/com/pm/apigateway/config/GatewayRouteConfig.java"
  click GW_C "https://github.com/sai-deekshith-06/playo/blob/main/services/api-gateway/src/main/java/com/pm/apigateway/config/CorsConfig.java"
  click GW_H "https://github.com/sai-deekshith-06/playo/blob/main/services/api-gateway/src/main/java/com/pm/apigateway/controller/HealthController.java"

  click EU "https://github.com/sai-deekshith-06/playo/tree/main/services/eureka-server/"
  click AU "https://github.com/sai-deekshith-06/playo/tree/main/services/auth-server/"
  click AU3 "https://github.com/sai-deekshith-06/playo/tree/main/services/auth-server/"

  click AC "https://github.com/sai-deekshith-06/playo/blob/main/services/auth-server/src/main/java/com/sportify/sports/auth/AuthController.java"
  click UPC "https://github.com/sai-deekshith-06/playo/blob/main/services/auth-server/src/main/java/com/sportify/sports/controller/UpdateProfileController.java"
  click SC "https://github.com/sai-deekshith-06/playo/blob/main/services/auth-server/src/main/java/com/sportify/sports/config/SecurityConfig.java"
  click JF "https://github.com/sai-deekshith-06/playo/blob/main/services/auth-server/src/main/java/com/sportify/sports/security/JwtAuthenticationFilter.java"
  click JS "https://github.com/sai-deekshith-06/playo/blob/main/services/auth-server/src/main/java/com/sportify/sports/security/JwtService.java"
  click CUP "https://github.com/sai-deekshith-06/playo/blob/main/services/auth-server/src/main/java/com/sportify/sports/security/CustomUserPrincipal.java"
  click CUDS "https://github.com/sai-deekshith-06/playo/blob/main/services/auth-server/src/main/java/com/sportify/sports/service/CustomUserDetailsService.java"
  click CIC "https://github.com/sai-deekshith-06/playo/blob/main/services/auth-server/src/main/java/com/sportify/sports/config/CloudinaryConfig.java"
  click UI "https://github.com/sai-deekshith-06/playo/blob/main/services/auth-server/src/main/java/com/sportify/sports/service/UploadImage.java"
  click UR "https://github.com/sai-deekshith-06/playo/blob/main/services/auth-server/src/main/java/com/sportify/sports/repository/UserRepository.java"
  click UENT "https://github.com/sai-deekshith-06/playo/blob/main/services/auth-server/src/main/java/com/sportify/sports/entity/User.java"
  click RENT "https://github.com/sai-deekshith-06/playo/blob/main/services/auth-server/src/main/java/com/sportify/sports/entity/Role.java"
  click DTO "https://github.com/sai-deekshith-06/playo/tree/main/services/auth-server/src/main/java/com/sportify/sports/dto/"
  click GEH "https://github.com/sai-deekshith-06/playo/blob/main/services/auth-server/src/main/java/com/sportify/sports/exception/GlobalExceptionHandler.java"

  %% Frontend specific click targets (mapped)
  click FE_DOM "https://github.com/sai-deekshith-06/playo/tree/main/frontend/src/Pages/book/"
  click FE_DOM "https://github.com/sai-deekshith-06/playo/tree/main/frontend/src/Pages/play/"
  click FE_DOM "https://github.com/sai-deekshith-06/playo/tree/main/frontend/src/Pages/trainer/"
  click FE_DOM "https://github.com/sai-deekshith-06/playo/tree/main/frontend/src/Pages/player/"
  click FE_DOM "https://github.com/sai-deekshith-06/playo/tree/main/frontend/src/components/"

  %% =========================
  %% STYLES
  %% =========================
  classDef client fill:#cfe8ff,stroke:#1e3a8a,stroke-width:1.5px,color:#0b1220
  classDef frontend fill:#bfe6ff,stroke:#075985,stroke-width:1.5px,color:#0b1220
  classDef backend fill:#c9f7d4,stroke:#166534,stroke-width:1.5px,color:#0b1220
  classDef backend2 fill:#e3ffd8,stroke:#166534,stroke-width:1.2px,color:#0b1220
  classDef security fill:#ffe0b2,stroke:#9a3412,stroke-width:1.5px,color:#0b1220
  classDef datastore fill:#ffd6a5,stroke:#9a3412,stroke-width:1.5px,color:#0b1220
  classDef external fill:#e5e7eb,stroke:#374151,stroke-width:1.5px,color:#111827
  classDef infra fill:#fef08a,stroke:#854d0e,stroke-width:1.5px,color:#111827
  classDef component fill:#ffffff,stroke:#334155,stroke-width:1.2px,color:#0b1220
  classDef system fill:#dbeafe,stroke:#1d4ed8,stroke-width:2px,color:#0b1220
  classDef future fill:#f3f4f6,stroke:#6b7280,stroke-dasharray: 4 3,stroke-width:1.2px,color:#111827
  classDef note fill:#fff7ed,stroke:#c2410c,stroke-width:1px,color:#111827
```
