# sathytrench/punk-calendar architecture

> Architecture diagram of the GitHub repository sathytrench/punk-calendar, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sathytrench/punk-calendar
- Repository: https://github.com/sathytrench/punk-calendar

## Overview

##### Main System Components

A. Frontend Layer:
- Next.js Application (Pages Router)
- TailwindCSS Styling
- Client-side tRPC API Integration

B. API Layer:
- tRPC Router System
- NextAuth Authentication
- API Routes (/api/events, /api/auth)

C. Database Layer:
- PostgreSQL Database
- Prisma ORM

D. External Services:
- Discord OAuth Provider

**[Client Layer]**
- ↕
**[Server Layer]**
- ↕
**[Data Layer]**

##### Detailed Component Breakdown

Frontend Layer (Blue):
**[Next.js Pages] → [TailwindCSS Styles]**
- ↓
**[tRPC Client Hooks]**

API/Server Layer (Green):
**[tRPC Router] → [Event Routes]**
- ↓
**[NextAuth.js] → [Auth Routes]**
- ↓
**[Prisma Client]**

Database Layer (Yellow):
**[PostgreSQL Database]**

External Services (Purple):
**[Discord OAuth]**

##### Key Relationships to Highlight

- TRPC connection between frontend and backend
- Authentication flow through Discord
- Demonstrate the Prisma ORM connection to PostgreSQL
- API routes for events and authentication

##### Important Implementation Details

- File structure organization (/src/pages, /src/server)
- Separation of API routes and tRPC endpoints
- Authentication integration points
- Database schema connection through Prisma

##### Specific Project Elements

For this punk calendar application, emphasize:
- Event data flow from submission to storage
- User authentication process via Discord
- API routes for event retrieval and manipulation
- Database schema for events and users

Remember to include a notes section explaining:
- The T3 Stack integration
- The role of NextAuth with Discord
- The PostgreSQL + Prisma implementation
- The tRPC API layer's significance

This will provide a complete picture of both the technical architecture and the business logic implementation specific to a community-driven calendar application.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        Pages["Next.js Pages"]
        Styles["TailwindCSS Styles"]
        ClientAPI["tRPC Client Integration"]
        Pages --> Styles
        Pages --> ClientAPI
    end

    subgraph API
        TRPC["tRPC Router System"]
        Auth["NextAuth.js"]
        Routes["API Routes"]
        TRPC --> Auth
        TRPC --> Routes
    end

    subgraph Database
        Prisma["Prisma ORM"]
        PostgreSQL[("PostgreSQL DB")]
        Prisma --> PostgreSQL
    end

    subgraph External
        Discord["Discord OAuth"]
    end

    ClientAPI --> TRPC
    Auth --> Discord
    Routes --> Prisma

    %% Component Mappings
    click Pages "https://github.com/sathytrench/punk-calendar/tree/main/src/pages"
    click Styles "https://github.com/sathytrench/punk-calendar/blob/main/src/styles/globals.css"
    click ClientAPI "https://github.com/sathytrench/punk-calendar/blob/main/src/utils/api.ts"
    click TRPC "https://github.com/sathytrench/punk-calendar/blob/main/src/server/api/root.ts"
    click Auth "https://github.com/sathytrench/punk-calendar/blob/main/src/server/auth.ts"
    click Routes "https://github.com/sathytrench/punk-calendar/blob/main/src/pages/api/events/[slug].ts"
    click Prisma "https://github.com/sathytrench/punk-calendar/blob/main/prisma/schema.prisma"

    %% Styling
    classDef frontend fill:#a8d1ff,stroke:#333,stroke-width:2px
    classDef api fill:#90EE90,stroke:#333,stroke-width:2px
    classDef database fill:#FFE5B4,stroke:#333,stroke-width:2px
    classDef external fill:#DDA0DD,stroke:#333,stroke-width:2px

    class Pages,Styles,ClientAPI frontend
    class TRPC,Auth,Routes api
    class Prisma,PostgreSQL database
    class Discord external

    %% Legend
    subgraph Legend
        Frontend_L["Frontend Component"]:::frontend
        API_L["API Component"]:::api
        DB_L["Database Component"]:::database
        Ext_L["External Service"]:::external
    end
```
