# realaashishly/pingpanda architecture

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

- Interactive diagram: https://gitdiagram.com/realaashishly/pingpanda
- Repository: https://github.com/realaashishly/pingpanda

## Overview

##### Main System Components

a) Client Layer:
- Next.js Frontend (src/app directory)
- Landing Pages ((landing) route)
- Authentication Pages ((auth) route)
- Dashboard Interface (dashboard route)

b) API Layer:
- Next.js API Routes (src/app/api)
- API Version Management (v1 endpoints)
- tRPC Server (src/server)

c) Service Layer:
- Authentication Service (Clerk integration)
- Event Monitoring Service
- Discord Notification Service (src/app/lib/discord-client.ts)
- Database Service (Prisma/PostgreSQL)

##### Component Relationships

a) Frontend to Backend:
- Client → API Routes
- Client → tRPC Procedures
- Authentication Flow → Clerk

b) Backend Services:
- API Routes → Event Monitoring
- Event Monitoring → Discord Notifications
- API Routes → Database Layer

##### Specific Implementation Details

Architectural patterns:

a) Next.js App Router Structure:
- Routes by feature ((auth), (landing), dashboard)
- API routes separation
- Server components architecture

b) Data Flow:
- Client requests → API/tRPC → Database
- Event triggers → Discord notifications

##### Key Technical Elements to Highlight

- Next.js App Router architecture
- tRPC implementation (src/server)
- Prisma ORM integration
- Authentication flow with Clerk
- Real-time event monitoring system
- Discord notification pipeline

**┌─ Client Layer ─────────────────────┐**
- Next.js Frontend                 │
- React Components                 │
- TailwindCSS UI                  │
- ┬─┘
- ↕                    │
**┌─ API Layer ──────────────────────┤**
- Next.js API Routes             │
- tRPC Procedures               │
- ┤
- ↕                    │
**┌─ Service Layer ───────────────────┤**
- Event Monitoring               │
- Discord Notifications          │
- Authentication                 │
- ┤
- ↕                    │
**┌─ Data Layer ─────────────────────┘**
- PostgreSQL                     │
- Prisma ORM                     │
- ┘

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef frontend fill:#3b82f6,color:white
    classDef api fill:#10b981,color:white
    classDef service fill:#f59e0b,color:white
    classDef database fill:#8b5cf6,color:white
    classDef external fill:#6b7280,color:white

    %% Client Layer
    subgraph ClientLayer["Client Layer"]
        Frontend["Next.js Frontend"]
        Landing["Landing Pages"]:::frontend
        Auth["Authentication Pages"]:::frontend
        Dashboard["Dashboard Interface"]:::frontend
        UIComponents["UI Components"]:::frontend
        FormValidators["Form Validators"]:::frontend
        ClientAPI["Client API Interface"]:::frontend
    end

    %% API Layer
    subgraph APILayer["API Layer"]
        APIRoutes["API Routes"]:::api
        tRPC["tRPC Server"]:::api
        Middleware["Middleware Pipeline"]:::api
    end

    %% Service Layer
    subgraph ServiceLayer["Service Layer"]
        AuthRouter["Authentication Router"]:::service
        ProjectRouter["Project Management"]:::service
        CategoryRouter["Category Management"]:::service
        EventMonitor["Event Monitoring"]:::service
        DiscordNotif["Discord Notification Service"]:::service
        Cache["Cache System"]:::service
    end

    %% Data Layer
    subgraph DataLayer["Data Layer"]
        Database["PostgreSQL/Prisma"]:::database
    end

    %% External Services
    Clerk["Clerk Authentication"]:::external
    Discord["Discord Service"]:::external

    %% Relationships
    Frontend --> Landing
    Frontend --> Auth
    Frontend --> Dashboard
    Frontend --> UIComponents
    Frontend --> FormValidators
    Frontend --> ClientAPI
    
    ClientAPI --> APIRoutes
    ClientAPI --> tRPC
    
    APIRoutes --> Middleware
    tRPC --> Middleware
    
    Middleware --> AuthRouter
    Middleware --> ProjectRouter
    Middleware --> CategoryRouter
    
    AuthRouter --> Clerk
    EventMonitor --> DiscordNotif
    DiscordNotif --> Discord
    
    AuthRouter --> Database
    ProjectRouter --> Database
    CategoryRouter --> Database
    Cache --> Database

    %% Click Events
    click Auth "https://github.com/realaashishly/PingPanda/tree/main/src/app/(auth)"
    click Landing "https://github.com/realaashishly/PingPanda/tree/main/src/app/(landing)"
    click Dashboard "https://github.com/realaashishly/PingPanda/tree/main/src/app/dashboard"
    click APIRoutes "https://github.com/realaashishly/PingPanda/tree/main/src/app/api/v1"
    click tRPC "https://github.com/realaashishly/PingPanda/tree/main/src/server"
    click DiscordNotif "https://github.com/realaashishly/PingPanda/blob/main/src/app/lib/discord-client.ts"
    click Database "https://github.com/realaashishly/PingPanda/blob/main/src/db.ts"
    click Cache "https://github.com/realaashishly/PingPanda/blob/main/src/server/__internals/db/cache-extension.ts"
    click Middleware "https://github.com/realaashishly/PingPanda/blob/main/src/middleware.ts"
    click AuthRouter "https://github.com/realaashishly/PingPanda/blob/main/src/server/routers/auth-router.ts"
    click UIComponents "https://github.com/realaashishly/PingPanda/tree/main/src/components/ui"
    click ClientAPI "https://github.com/realaashishly/PingPanda/blob/main/src/app/lib/client.ts"
    click FormValidators "https://github.com/realaashishly/PingPanda/tree/main/src/app/lib/validators"
    click ProjectRouter "https://github.com/realaashishly/PingPanda/blob/main/src/server/routers/project-router.ts"
    click CategoryRouter "https://github.com/realaashishly/PingPanda/blob/main/src/server/routers/category-router.ts"

    %% Legend
    subgraph Legend
        Frontend_L["Frontend"]:::frontend
        API_L["API"]:::api
        Service_L["Service"]:::service
        Database_L["Database"]:::database
        External_L["External"]:::external
    end
```
