# rfwilliams11/pick-em architecture

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

- Interactive diagram: https://gitdiagram.com/rfwilliams11/pick-em
- Repository: https://github.com/rfwilliams11/pick-em

## Overview

##### Main Components

A. Client-Side (Frontend):
- Next.js App Router Structure
- Auth Routes (/login, /signup)
- Dashboard Routes (/picks, /admin)
- Public Routes
- UI Components Layer (shadcn/ui components)
- Context Providers (AuthContext)

B. Server-Side (Backend):
- API Routes Layer (Next.js API routes)
- Authentication System (NextAuth.js)
- Database Layer (likely PostgreSQL with Drizzle ORM)

**┌─ Client Layer ─────────────────┐**
- Next.js Pages               │
- React Components            │
- UI Components               │
- ┬───────────────────┘
- ↕ (HTTP/API Calls)
**┌─ Server Layer ─────────────────┐**
- API Routes                   │
- Authentication Middleware    │
- Business Logic              │
- ┬───────────────────┘
- ↕ (Database Queries)
**┌─ Data Layer ──────────────────┐**
- PostgreSQL Database         │
- Drizzle ORM                 │
- ┘

##### Key Relationships to Highlight

a. Authentication Flow:
- Session management between client and server

b. Game Management Flow:
- Admin routes → Games API → Database
- Picks submission flow: User → Picks API → Database

c. Data Access Patterns:
- How the dashboard accesses game data, user records, and picks
- Real-time updates if implemented

##### Specific Implementation Details

Project-specific elements:
**┌─ Feature Modules ──────────────┐**
- Game Management             │
- Pick Submission             │
- User Records                │
- Leaderboard                 │
- ┘

**┌─ Database Schema ─────────────┐**
- Users                      │
- Games                      │
- Picks                      │
- Teams                      │
- Rounds                     │
- ┘

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Layer"]
        direction TB
        Auth["Authentication Pages"]
        Dashboard["Dashboard Interface"]
        Public["Public Pages"]
        UIComponents["UI Components"]
        GameCard["Game Card Component"]
    end

    subgraph Server["Server Layer"]
        direction TB
        APIRoutes["API Routes"]
        AuthSystem["Authentication System"]
        Middleware["Security Middleware"]
        BusinessLogic["Business Logic"]
    end

    subgraph Data["Data Layer"]
        direction TB
        DB[(PostgreSQL)]
        ORM["Drizzle ORM"]
        Schema["Database Schema"]
    end

    subgraph Features["Feature Modules"]
        direction TB
        GameMgmt["Game Management"]
        PickSystem["Pick Submission"]
        UserRecords["User Records"]
        Leaderboard["Leaderboard"]
    end

    %% Relationships
    Auth --> AuthSystem
    Dashboard --> APIRoutes
    APIRoutes --> BusinessLogic
    BusinessLogic --> ORM
    ORM --> DB
    Middleware --> AuthSystem
    GameMgmt --> APIRoutes
    PickSystem --> APIRoutes
    UserRecords --> APIRoutes

    %% Component Styling
    classDef frontend fill:#3b82f6,color:#fff
    classDef backend fill:#22c55e,color:#fff
    classDef database fill:#7c3aed,color:#fff
    classDef auth fill:#eab308,color:#fff
    classDef feature fill:#ef4444,color:#fff

    %% Apply Classes
    class Auth,Dashboard,Public,UIComponents,GameCard frontend
    class APIRoutes,BusinessLogic,Middleware backend
    class DB,ORM,Schema database
    class AuthSystem auth
    class GameMgmt,PickSystem,UserRecords,Leaderboard feature

    %% Click Events
    click Auth "https://github.com/rfwilliams11/pick-em/tree/main/app/(auth)/*"
    click AuthSystem "https://github.com/rfwilliams11/pick-em/blob/main/lib/auth.ts"
    click Dashboard "https://github.com/rfwilliams11/pick-em/blob/main/app/(dashboard)/layout.tsx"
    click UIComponents "https://github.com/rfwilliams11/pick-em/tree/main/components/ui/*"
    click GameCard "https://github.com/rfwilliams11/pick-em/blob/main/app/(dashboard)/picks/game-card.tsx"
    click Middleware "https://github.com/rfwilliams11/pick-em/blob/main/middleware.ts"
    click Schema "https://github.com/rfwilliams11/pick-em/blob/main/lib/schema.ts"
    click ORM "https://github.com/rfwilliams11/pick-em/blob/main/lib/db.ts"
    click GameMgmt "https://github.com/rfwilliams11/pick-em/tree/main/app/(dashboard)/admin/*"
    click PickSystem "https://github.com/rfwilliams11/pick-em/tree/main/app/(dashboard)/picks/*"
    click UserRecords "https://github.com/rfwilliams11/pick-em/blob/main/app/(dashboard)/user-records.tsx"
    click APIRoutes "https://github.com/rfwilliams11/pick-em/tree/main/app/api/*"

    %% Legend
    subgraph Legend
        direction TB
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Component"]:::backend
        DatabaseComp["Database Component"]:::database
        AuthComp["Auth Component"]:::auth
        FeatureComp["Feature Component"]:::feature
    end
```
