# thegeekyb0y/dsbored121 architecture

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

- Interactive diagram: https://gitdiagram.com/thegeekyb0y/dsbored121
- Repository: https://github.com/thegeekyb0y/dsbored121

## Overview

##### Project type and purpose
- This is a full-stack web application built with Next.js 13 (app directory), React, TypeScript, Prisma, and Pusher.
- Purpose: “Kraked: Study Together” enables users to create/join study rooms, track study sessions in real time, view stats, and collaborate.

##### File structure
- app/api – Serverless (Next.js) route handlers for authentication (NextAuth), room management, session lifecycle (start, pause, resume, stop, stats), and real-time test endpoints.
- app/components – React UI components (timers, charts, selectors, layouts).
- app/hooks – Custom React hooks (usePusher, useStopwatch, useTimer) for client-side state and real-time events.
- app/lib – Shared libraries: Prisma client initialization, Pusher setup, authentication utilities.
- prisma – Database schema (Prisma) and migration scripts for sessions, rooms, active/pause state.
- public – Static assets (study material docs).
- next.config.ts, tsconfig.json, postcss.config.mjs – Build and configuration files.
- components/ui – Standalone UI primitives (card, chart).
- lib/utils.ts and types/next-auth.d.ts – Utility functions and type definitions.

##### README for additional insights
- Confirms the “Study Together” use case with a live deployment link.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    subgraph "Client (Next.js App)" 
        direction TB
        subgraph "Pages" 
            direction TB
            PageHome["Home Page (app/page.tsx)"]:::client
            PageRoomDetail["Room Detail (app/rooms/[code]/page.tsx)"]:::client
            PageRoomNew["New Room (app/rooms/new/page.tsx)"]:::client
            PageRooms["Rooms List (app/rooms/page.tsx)"]:::client
            PageTimer["Timer (app/timer/page.tsx)"]:::client
            PageStats["Stats (app/stats/page.tsx)"]:::client
            PageTest["Test Pusher (app/test-pusher/page.tsx)"]:::client
        end
        subgraph "Components" 
            direction TB
            CompActivity["ActivityComponent"]:::client
            CompAppBar["AppBar"]:::client
            CompAppLayout["AppLayout"]:::client
            CompLiveTimer["LiveTimer"]:::client
            CompModeSelector["ModeSelector"]:::client
            CompPause["PauseComp"]:::client
            CompRoomsSkeleton["RoomsSkeleton"]:::client
            CompStatsChart["StatsChart"]:::client
            CompStopwatch["Stopwatch"]:::client
            CompSubjectPie["SubjectPie"]:::client
            CompSubjectSelect["SubjectSelect"]:::client
            CompTimer["TimerComp"]:::client
            CompUnifiedTimer["UnifiedTimer"]:::client
            CompWeeklyChart["WeeklyChart"]:::client
        end
        subgraph "Hooks" 
            direction TB
            HookPusher["usePusher"]:::client
            HookStopwatch["useStopwatch"]:::client
            HookTimer["useTimer"]:::client
        end
    end

    %% Server Side
    subgraph "Server (Next.js API)" 
        direction TB
        subgraph "Auth API" 
            direction TB
            AuthRoute["[...nextauth] route"]:::api
            AuthLib["auth utils (app/lib/auth.ts)"]:::api
            AuthTypes["NextAuth Types"]:::api
        end
        subgraph "Room Management API" 
            direction TB
            RoomCreate["rooms/create"]:::api
            RoomJoin["rooms/join"]:::api
            RoomMy["rooms/my-rooms"]:::api
            RoomDetailAPI["rooms/[code]"]:::api
            RoomActive["rooms/[code]/active"]:::api
        end
        subgraph "Session Lifecycle API" 
            direction TB
            SessionStart["sessions/start"]:::api
            SessionPause["sessions/pause"]:::api
            SessionResume["sessions/resume"]:::api
            SessionStop["sessions/stop"]:::api
            SessionActive["sessions/active"]:::api
            SessionStats["sessions/stats"]:::api
        end
        subgraph "Test Endpoint" 
            direction TB
            TestPush["test-pusher"]:::api
        end
        subgraph "Lib" 
            direction TB
            PrismaClient["Prisma Client (app/lib/prisma.ts)"]:::api
            PusherClient["Pusher Setup (app/lib/pusher.ts)"]:::api
        end
    end

    %% External Services
    Database[(Database)]:::db
    Pusher[(Pusher Service)]:::ext
    Vercel[(Vercel Hosting)]:::ext

    %% Connections
    %% Client to API
    PageHome -->|calls| AuthRoute
    PageRoomDetail -->|calls| RoomDetailAPI
    PageRoomNew -->|calls| RoomCreate
    PageRooms -->|calls| RoomMy
    PageTimer -->|calls| SessionStart
    PageTimer -->|calls| SessionPause
    PageTimer -->|calls| SessionResume
    PageTimer -->|calls| SessionStop
    PageStats -->|calls| SessionStats
    PageTest -->|calls| TestPush

    %% API to DB
    AuthRoute -->|queries| PrismaClient
    RoomCreate -->|reads/writes| PrismaClient
    RoomJoin -->|reads/writes| PrismaClient
    RoomMy -->|reads| PrismaClient
    RoomDetailAPI -->|reads| PrismaClient
    RoomActive -->|reads| PrismaClient
    SessionStart -->|writes| PrismaClient
    SessionPause -->|writes| PrismaClient
    SessionResume -->|writes| PrismaClient
    SessionStop -->|writes| PrismaClient
    SessionActive -->|reads| PrismaClient
    SessionStats -->|reads| PrismaClient

    %% API to Pusher
    SessionStart -->|publish| PusherClient
    SessionPause -->|publish| PusherClient
    SessionResume -->|publish| PusherClient
    SessionStop -->|publish| PusherClient
    TestPush -->|publish| PusherClient

    %% Real-time to Client
    PusherClient -->|events| HookPusher
    HookPusher -->|updates| CompLiveTimer

    %% Hosting
    AuthRoute -->|deployed on| Vercel
    RoomCreate -->|deployed on| Vercel
    SessionStart -->|deployed on| Vercel

    %% Click Events - Client
    click PageHome "https://github.com/thegeekyb0y/dsbored121/blob/main/app/page.tsx"
    click PageRoomDetail "https://github.com/thegeekyb0y/dsbored121/blob/main/app/rooms/[code]/page.tsx"
    click PageRoomNew "https://github.com/thegeekyb0y/dsbored121/blob/main/app/rooms/new/page.tsx"
    click PageRooms "https://github.com/thegeekyb0y/dsbored121/blob/main/app/rooms/page.tsx"
    click PageTimer "https://github.com/thegeekyb0y/dsbored121/blob/main/app/timer/page.tsx"
    click PageStats "https://github.com/thegeekyb0y/dsbored121/blob/main/app/stats/page.tsx"
    click PageTest "https://github.com/thegeekyb0y/dsbored121/blob/main/app/test-pusher/page.tsx"
    click CompActivity "https://github.com/thegeekyb0y/dsbored121/blob/main/app/components/ActivityComponent.tsx"
    click CompAppBar "https://github.com/thegeekyb0y/dsbored121/blob/main/app/components/AppBar.tsx"
    click CompAppLayout "https://github.com/thegeekyb0y/dsbored121/blob/main/app/components/AppLayout.tsx"
    click CompLiveTimer "https://github.com/thegeekyb0y/dsbored121/blob/main/app/components/LiveTimer.tsx"
    click CompModeSelector "https://github.com/thegeekyb0y/dsbored121/blob/main/app/components/ModeSelector.tsx"
    click CompPause "https://github.com/thegeekyb0y/dsbored121/blob/main/app/components/PauseComp.tsx"
    click CompRoomsSkeleton "https://github.com/thegeekyb0y/dsbored121/blob/main/app/components/RoomsSkeleton.tsx"
    click CompStatsChart "https://github.com/thegeekyb0y/dsbored121/blob/main/app/components/StatsChart.tsx"
    click CompStopwatch "https://github.com/thegeekyb0y/dsbored121/blob/main/app/components/Stopwatch.tsx"
    click CompSubjectPie "https://github.com/thegeekyb0y/dsbored121/blob/main/app/components/SubjectPie.tsx"
    click CompSubjectSelect "https://github.com/thegeekyb0y/dsbored121/blob/main/app/components/SubjectSelect.tsx"
    click CompTimer "https://github.com/thegeekyb0y/dsbored121/blob/main/app/components/TimerComp.tsx"
    click CompUnifiedTimer "https://github.com/thegeekyb0y/dsbored121/blob/main/app/components/UnifiedTimer.tsx"
    click CompWeeklyChart "https://github.com/thegeekyb0y/dsbored121/blob/main/app/components/WeeklyChart.tsx"
    click HookPusher "https://github.com/thegeekyb0y/dsbored121/blob/main/app/hooks/usePusher.ts"
    click HookStopwatch "https://github.com/thegeekyb0y/dsbored121/blob/main/app/hooks/useStopwatch.ts"
    click HookTimer "https://github.com/thegeekyb0y/dsbored121/blob/main/app/hooks/useTimer.ts"

    %% Click Events - Server
    click AuthRoute "https://github.com/thegeekyb0y/dsbored121/blob/main/app/api/auth/[...nextauth]/route.ts"
    click AuthLib "https://github.com/thegeekyb0y/dsbored121/blob/main/app/lib/auth.ts"
    click AuthTypes "https://github.com/thegeekyb0y/dsbored121/blob/main/types/next-auth.d.ts"
    click RoomCreate "https://github.com/thegeekyb0y/dsbored121/blob/main/app/api/rooms/create/route.ts"
    click RoomJoin "https://github.com/thegeekyb0y/dsbored121/blob/main/app/api/rooms/join/route.ts"
    click RoomMy "https://github.com/thegeekyb0y/dsbored121/blob/main/app/api/rooms/my-rooms/route.ts"
    click RoomDetailAPI "https://github.com/thegeekyb0y/dsbored121/blob/main/app/api/rooms/[code]/route.ts"
    click RoomActive "https://github.com/thegeekyb0y/dsbored121/blob/main/app/api/rooms/[code]/active/route.ts"
    click SessionStart "https://github.com/thegeekyb0y/dsbored121/blob/main/app/api/sessions/start/route.ts"
    click SessionPause "https://github.com/thegeekyb0y/dsbored121/blob/main/app/api/sessions/pause/route.ts"
    click SessionResume "https://github.com/thegeekyb0y/dsbored121/blob/main/app/api/sessions/resume/route.ts"
    click SessionStop "https://github.com/thegeekyb0y/dsbored121/blob/main/app/api/sessions/stop/route.ts"
    click SessionActive "https://github.com/thegeekyb0y/dsbored121/blob/main/app/api/sessions/active/route.ts"
    click SessionStats "https://github.com/thegeekyb0y/dsbored121/blob/main/app/api/sessions/stats/route.ts"
    click TestPush "https://github.com/thegeekyb0y/dsbored121/blob/main/app/api/test-pusher/route.ts"
    click PrismaClient "https://github.com/thegeekyb0y/dsbored121/blob/main/app/lib/prisma.ts"
    click PusherClient "https://github.com/thegeekyb0y/dsbored121/blob/main/app/lib/pusher.ts"
    click Database "https://github.com/thegeekyb0y/dsbored121/blob/main/prisma/schema.prisma"
    click Database "https://github.com/thegeekyb0y/dsbored121/tree/main/prisma/migrations/"
    click Vercel "https://github.com/thegeekyb0y/dsbored121/blob/main/next.config.ts"

    %% Styles
    classDef client fill:#cfe2f3,stroke:#0b5394,color:#0b5394
    classDef api fill:#d9ead3,stroke:#38761d,color:#38761d
    classDef db fill:#f9cb9c,stroke:#e69138,color:#e69138
    classDef ext fill:#e1bee7,stroke:#6a1b9a,color:#6a1b9a
```
