# yashksaini-coder/leetcode-journal architecture

> Architecture diagram of the GitHub repository yashksaini-coder/leetcode-journal, 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/yashksaini-coder/leetcode-journal
- Repository: https://github.com/yashksaini-coder/leetcode-journal

## Overview

##### Main Components

a) Frontend Layer:
- Next.js Application (app directory structure)
- UI Components (/components directory)
- Client-side State Management (store/AuthStore)
- Theme System (components/theme-provider.tsx)

b) Backend Layer:
- Next.js API Routes (/app/api)
- Authentication System (/app/api/auth)
- LeetCode Integration (/app/api/leetcode)
- GraphQL Queries (GQL_Queries directory)

c) Database Layer:
- Supabase (Primary database)
- Prisma ORM (prisma directory)

d) External Services:
- LeetCode API Integration
- Authentication Service (Supabase Auth)
- Vercel Deployment

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

##### Detailed Component Relationships

Frontend Components:
**[Landing Page] → [Dashboard] → [Profile]**
- ↓
**[Authentication Pages]**
- ↓
**[Blog System] → [FAQ Section]**

Backend Services:
**[Next.js API Routes]**
- ↙     ↓     ↘
**[Auth] [LeetCode] [User]**
- ↓     ↓        ↓
**[Supabase + Prisma Database]**

##### Important Architectural Patterns to Highlight

- App Router Pattern (Next.js 13+ structure)
- API Route Controllers (/api/leetcode/controllers)
- Server-side and Client-side Components
- Database Schema (prisma/schema.prisma)

##### Key Integration Points

- Authentication flow between frontend and Supabase
- LeetCode API data flow
- Demonstrate blog content management system
- User data flow through the system

##### Additional Elements

Specific features:
- AI Agent integration
- Progress tracking system
- Analytics pipeline
- Problem categorization system

- Component types
- Data flow directions
- Authentication boundaries
- External service integrations

This system design should emphasize the modern Next.js architecture while showing how the application integrates with Supabase, Prisma, and the LeetCode API to provide its core functionality of tracking and analyzing users' LeetCode progress.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "User Interface Layer"
        UI_Landing["Landing Page"]
        UI_Dashboard["Dashboard Interface"]:::dashboard
        UI_Auth["Authentication UI"]:::auth
        UI_Blog["Blog System"]:::blog
        UI_FAQ["FAQ System"]:::faq
        UI_Analytics["Analytics Component"]:::analytics
    end

    subgraph "Application Layer"
        APP_Router["Next.js App Router"]
        APP_Components["Frontend Components"]:::ui
        APP_State["State Management"]:::state
        APP_Types["Type Definitions"]:::types
        APP_Validation["Data Validation"]:::validation
    end

    subgraph "Service Layer"
        SVC_Auth["Authentication Service"]:::authapi
        SVC_Leetcode["LeetCode Integration"]:::leetcode
        SVC_AuthStore["Authentication Store"]:::authstore
    end

    subgraph "Data Access Layer"
        DAL_GraphQL["GraphQL Layer"]:::graphql
        DAL_Prisma["Prisma ORM"]:::prisma
        DAL_Supabase["Supabase Client"]:::supabase
    end

    subgraph "External Services"
        EXT_LeetCode["LeetCode API"]
        EXT_Auth["Auth Provider"]
        EXT_Deployment["Vercel"]
    end

    %% Connections
    UI_Landing --> APP_Router
    UI_Dashboard --> APP_Router
    UI_Auth --> APP_Router
    UI_Blog --> APP_Router
    UI_FAQ --> APP_Router
    UI_Analytics --> APP_Router

    APP_Router --> SVC_Auth
    APP_Router --> SVC_Leetcode
    APP_Router --> APP_State
    APP_State --> SVC_AuthStore

    SVC_Auth --> DAL_Supabase
    SVC_Leetcode --> EXT_LeetCode
    SVC_Auth --> EXT_Auth

    DAL_GraphQL --> DAL_Prisma
    DAL_Prisma --> DAL_Supabase

    %% Click Events
    click UI_Dashboard "https://github.com/yashksaini-coder/Leetcode-Journal/tree/main/app/dashboard/*"
    click UI_Auth "https://github.com/yashksaini-coder/Leetcode-Journal/tree/main/app/auth/*"
    click UI_Blog "https://github.com/yashksaini-coder/Leetcode-Journal/tree/main/app/blogs/*"
    click UI_FAQ "https://github.com/yashksaini-coder/Leetcode-Journal/tree/main/app/FAQ/*"
    click UI_Analytics "https://github.com/yashksaini-coder/Leetcode-Journal/blob/main/components/Stats.tsx"
    click APP_Components "https://github.com/yashksaini-coder/Leetcode-Journal/tree/main/components/ui/*"
    click APP_Types "https://github.com/yashksaini-coder/Leetcode-Journal/blob/main/types/typeInterfaces.ts"
    click APP_Validation "https://github.com/yashksaini-coder/Leetcode-Journal/blob/main/validations/validation.ts"
    click SVC_Auth "https://github.com/yashksaini-coder/Leetcode-Journal/tree/main/app/api/auth/*"
    click SVC_Leetcode "https://github.com/yashksaini-coder/Leetcode-Journal/tree/main/app/api/leetcode/*"
    click SVC_AuthStore "https://github.com/yashksaini-coder/Leetcode-Journal/blob/main/store/AuthStore/useAuthStore.ts"
    click DAL_GraphQL "https://github.com/yashksaini-coder/Leetcode-Journal/tree/main/GQL_Queries/*"
    click DAL_Prisma "https://github.com/yashksaini-coder/Leetcode-Journal/blob/main/prisma/schema.prisma"
    click DAL_Supabase "https://github.com/yashksaini-coder/Leetcode-Journal/blob/main/lib/supabaseClient.ts"
    click APP_State "https://github.com/yashksaini-coder/Leetcode-Journal/tree/main/store/AuthStore/*"

    %% Styling
    classDef frontend fill:#a8d5ff
    classDef backend fill:#90EE90
    classDef database fill:#FFE5B4
    classDef external fill:#E6E6FA
    classDef auth fill:#FFB6C1
    classDef utility fill:#D3D3D3

    classDef dashboard fill:#a8d5ff
    classDef authapi fill:#90EE90
    classDef blog fill:#a8d5ff
    classDef faq fill:#a8d5ff
    classDef analytics fill:#a8d5ff
    classDef ui fill:#a8d5ff
    classDef state fill:#D3D3D3
    classDef types fill:#D3D3D3
    classDef validation fill:#D3D3D3
    classDef leetcode fill:#90EE90
    classDef authstore fill:#FFB6C1
    classDef graphql fill:#FFE5B4
    classDef prisma fill:#FFE5B4
    classDef supabase fill:#FFE5B4
```
