# adrianhajdin/yc_directory architecture

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

- Interactive diagram: https://gitdiagram.com/adrianhajdin/yc_directory
- Repository: https://github.com/adrianhajdin/yc_directory

## Overview

##### Main System Components

a) Client Layer:
- Next.js Frontend (App Router)
- UI Components (ShadCN)
- Client-side Authentication
- Error Boundaries (Sentry integration)

b) Server Layer:
- Next.js API Routes
- Server Actions
- Authentication Service (NextAuth)
- GitHub OAuth Integration

c) Data Layer:
- Sanity CMS
- Content Management Studio
- Real-time Updates
- Content API

##### Component Relationships

**[Client Layer]**
- ↑↓
**[Server Layer]**
- ↑↓
**[Data Layer]**

##### Detailed Component Breakdown

Frontend (App Router):
- Root Layout (/app/layout.tsx)
- Authentication Pages
- Startup Pages
- User Profile Pages
- Studio Integration

API Routes:
- Authentication Endpoints
- Sentry Integration
- Server Actions

Database Schema (Sanity):
- Startup Schema
- Author Schema
- Playlist Schema

##### Key Flows to Highlight

Authentication Flow:
**User → GitHub OAuth → NextAuth → Session Management → Protected Routes**

Content Management Flow:
**Sanity Studio → Content API → Server Actions → Client Components**

##### Technical Stack Indicators

- Next.js 15
- React 19
- TypeScript
- Tailwind CSS
- Sanity
- ShadCN
- GitHub OAuth

##### Important Implementation Details

Features:
- Live Content API integration
- Authentication system
- View tracking system
- Search functionality
- Editor picks feature

Keep the abstraction level high enough to understand the system architecture but detailed enough to show the unique features of this startup directory platform, particularly the integration between Next.js and Sanity, and the authentication flow with GitHub.

Remember to emphasize the modern Next.js 15 architecture with the App Router pattern and server components, as these are crucial aspects of the system's design.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Frontend["Next.js Frontend"]:::frontend
        UIComponents["UI Components (ShadCN)"]:::frontend
        ErrorBoundaries["Error Boundaries"]:::frontend
        NavComponent["Navigation"]:::frontend
        SearchComp["Search Component"]:::frontend
        StartupForm["Startup Form"]:::frontend
    end

    subgraph Server
        APIRoutes["API Routes"]:::server
        ServerActions["Server Actions"]:::server
        AuthService["Authentication Service"]:::server
        FormValidation["Form Validation"]:::server
        ErrorTracking["Error Tracking"]:::server
    end

    subgraph Data
        SanityCMS["Sanity CMS"]:::data
        ContentStudio["Content Studio"]:::data
        ContentAPI["Content API"]:::data
        RealTimeUpdates["Real-time Updates"]:::data
        
        subgraph Schemas
            StartupSchema["Startup Schema"]:::schema
            AuthorSchema["Author Schema"]:::schema
            PlaylistSchema["Playlist Schema"]:::schema
        end
    end

    Frontend --> ServerActions
    Frontend --> APIRoutes
    UIComponents --> Frontend
    ErrorBoundaries --> Frontend
    NavComponent --> Frontend
    SearchComp --> Frontend
    StartupForm --> ServerActions

    APIRoutes --> AuthService
    APIRoutes --> ErrorTracking
    ServerActions --> FormValidation
    ServerActions --> ContentAPI

    ContentAPI --> SanityCMS
    ContentStudio --> SanityCMS
    RealTimeUpdates --> SanityCMS
    Schemas --> SanityCMS

    classDef frontend fill:#2563eb,color:white
    classDef server fill:#dc2626,color:white
    classDef data fill:#16a34a,color:white
    classDef schema fill:#ca8a04,color:white

    click Frontend "https://github.com/adrianhajdin/yc_directory/tree/main/app/(root)/"
    click UIComponents "https://github.com/adrianhajdin/yc_directory/tree/main/components/ui/"
    click ErrorBoundaries "https://github.com/adrianhajdin/yc_directory/blob/main/app/global-error.tsx"
    click AuthService "https://github.com/adrianhajdin/yc_directory/blob/main/app/api/auth/[...nextauth]/route.ts"
    click ServerActions "https://github.com/adrianhajdin/yc_directory/blob/main/lib/actions.ts"
    click SanityCMS "https://github.com/adrianhajdin/yc_directory/blob/main/sanity/lib/client.ts"
    click ContentStudio "https://github.com/adrianhajdin/yc_directory/blob/main/app/studio/[[...tool]]/page.tsx"
    click StartupSchema "https://github.com/adrianhajdin/yc_directory/blob/main/sanity/schemaTypes/startup.ts"
    click AuthorSchema "https://github.com/adrianhajdin/yc_directory/blob/main/sanity/schemaTypes/author.ts"
    click PlaylistSchema "https://github.com/adrianhajdin/yc_directory/blob/main/sanity/schemaTypes/playlist.ts"
    click ContentAPI "https://github.com/adrianhajdin/yc_directory/blob/main/sanity/lib/queries.ts"
    click FormValidation "https://github.com/adrianhajdin/yc_directory/blob/main/lib/validation.ts"
    click NavComponent "https://github.com/adrianhajdin/yc_directory/blob/main/components/Navbar.tsx"
    click SearchComp "https://github.com/adrianhajdin/yc_directory/blob/main/components/SearchForm.tsx"
    click StartupForm "https://github.com/adrianhajdin/yc_directory/blob/main/components/StartupForm.tsx"
    click ErrorTracking "https://github.com/adrianhajdin/yc_directory/blob/main/sentry.client.config.ts"
    click RealTimeUpdates "https://github.com/adrianhajdin/yc_directory/blob/main/sanity/lib/live.ts"
```
