# ben-jamming-reilly/parasocial architecture

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

- Interactive diagram: https://gitdiagram.com/ben-jamming-reilly/parasocial
- Repository: https://github.com/ben-jamming-reilly/parasocial

## Overview

##### Main System Components

a) Client Layer:
- Next.js Frontend (src/app directory)
- React Components (src/components)
- Client-side State Management (src/hooks)

b) API Layer:
- tRPC API Routes (src/server/api/routers)
- Authentication (NextAuth.js)
- Video Query Service Integration

c) Service Layer:
- Video Query Services (src/server/video-query)
- Database Layer (Prisma)

##### Component Relationships

Frontend → API:
- TRPC client connections (src/trpc)
- Auth flows with NextAuth
- Video search requests

API → Services:
- Video query service interactions
- Database operations
- Authentication validations

##### Specific Implementation Details

Key architectural elements:

a) Frontend Components:
- Main pages (home, search, profile, video viewer)
- UI components (src/components/ui)
- Authentication provider
- Search interface

b) API Routes:
- tRPC routers for:
- Profile management
- Search functionality
- User operations
- Video handling

c) Service Integration:
- Video Query API client
- Search service
- Profile service
- Cluster service

##### Data Flow Visualization

Following flows:

##### User Authentication
**Client → NextAuth → Database**

##### Search Flow
**SearchBar → tRPC API → Video Query Service → Search Results → Client**

##### Profile Management
**Profile Components → tRPC API → Database → Client**

##### Key Technologies to Highlight

- Next.js 13+ (App Router)
- tRPC
- Prisma
- NextAuth
- Tailwind CSS
- Custom Video Query API

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        FE[Next.js Frontend]
        RC[React Components]
        CSM[Client State Management]
        UI[UI Components Library]
        AP[Auth Provider]
        SB[Search Bar]
    end

    subgraph API
        TR[tRPC Routers]
        NA[NextAuth]
        
        subgraph APIRoutes
            SR[Search Router]
            PR[Profile Router]
            VR[Video Router]
        end
    end

    subgraph Services
        VQS[Video Query Service]
        
        subgraph ServiceImplementations
            SS[Search Service]
            PS[Profile Service]
            VS[Videos Service]
        end
    end

    subgraph Data
        DB[(Database)]
    end

    %% Client Layer Connections
    FE --> TR
    RC --> TR
    SB --> SR
    AP --> NA

    %% API Layer Connections
    TR --> VQS
    TR --> DB
    NA --> DB

    %% Service Layer Connections
    SR --> SS
    PR --> PS
    VR --> VS
    SS --> DB
    PS --> DB
    VS --> DB

    %% Click Events
    click FE "https://github.com/ben-jamming-reilly/parasocial/tree/main/src/app"
    click RC "https://github.com/ben-jamming-reilly/parasocial/tree/main/src/components"
    click CSM "https://github.com/ben-jamming-reilly/parasocial/tree/main/src/hooks"
    click UI "https://github.com/ben-jamming-reilly/parasocial/tree/main/src/components/ui"
    click AP "https://github.com/ben-jamming-reilly/parasocial/blob/main/src/app/AuthProvider.tsx"
    click SB "https://github.com/ben-jamming-reilly/parasocial/blob/main/src/components/SearchBar.tsx"
    click TR "https://github.com/ben-jamming-reilly/parasocial/tree/main/src/server/api/routers"
    click NA "https://github.com/ben-jamming-reilly/parasocial/blob/main/src/server/auth.ts"
    click SR "https://github.com/ben-jamming-reilly/parasocial/blob/main/src/server/api/routers/search.ts"
    click PR "https://github.com/ben-jamming-reilly/parasocial/blob/main/src/server/api/routers/profile.ts"
    click VR "https://github.com/ben-jamming-reilly/parasocial/blob/main/src/server/api/routers/video.ts"
    click VQS "https://github.com/ben-jamming-reilly/parasocial/tree/main/src/server/video-query"
    click SS "https://github.com/ben-jamming-reilly/parasocial/blob/main/src/server/video-query/services/SearchService.ts"
    click PS "https://github.com/ben-jamming-reilly/parasocial/blob/main/src/server/video-query/services/ProfileService.ts"
    click VS "https://github.com/ben-jamming-reilly/parasocial/blob/main/src/server/video-query/services/VideosService.ts"
    click DB "https://github.com/ben-jamming-reilly/parasocial/blob/main/prisma/schema.prisma"

    %% Styling
    classDef client fill:#a8dadc,stroke:#1d3557
    classDef api fill:#457b9d,stroke:#1d3557,color:#fff
    classDef service fill:#e63946,stroke:#1d3557
    classDef data fill:#f1faee,stroke:#1d3557
    
    class FE,RC,CSM,UI,AP,SB client
    class TR,NA,SR,PR,VR api
    class VQS,SS,PS,VS service
    class DB data
```
