# jcgentr/article-summarizer architecture

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

- Interactive diagram: https://gitdiagram.com/jcgentr/article-summarizer
- Repository: https://github.com/jcgentr/article-summarizer

## Overview

##### Main Components

A. Frontend Layer:
- Public Routes (/login, /signup, /error)
- Protected Routes (main application area)
- UI Components (organized in components/ directory)
- Theme System (with dark/light mode support)

B. Application Layer:
- Next.js Server Components
- Server Actions (visible in various actions.ts files)
- Authentication Middleware
- Route Handlers

C. Backend Services:
- Supabase Integration (visible in utils/supabase/)
- AI Services (indicated by lib/ai.ts)

**[Client Browser]**
- ↕
**[Next.js Application]**

- [Public Routes]
- Login Page
- Signup Page
- Error Page

- [Protected Routes]
- Main Application
- Article Management

- [Components Layer]
- UI Components
- Article Components
- Theme Components

- [Middleware Layer]
- Auth Middleware
- Supabase Middleware

- [External Services]
- Supabase
- AI Service

##### Important Details to Highlight

A. Authentication Flow:
- Path from login/signup through middleware to protected routes
- Role of the auth/confirm route handler

B. Data Flow:
- Demonstrate how server actions interact with Supabase
- Relationship between UI components and their data sources

C. Application Architecture:
- Next.js App Router structure (public vs protected routes)
- Separation of concerns between components, actions, and utilities

##### Technical Stack Indicators

Badges or labels for:
- Next.js 13+ (App Router)
- Supabase
- TypeScript
- Tailwind CSS
- Shadcn UI (indicated by the components/ui directory)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Client Browser"]
    end

    subgraph NextApp["Next.js Application"]
        subgraph PublicRoutes["Public Routes"]
            Login["Login Page"]:::public
            Signup["Signup Page"]:::public
            Error["Error Page"]:::public
        end

        subgraph ProtectedRoutes["Protected Routes"]
            MainApp["Main Application"]:::protected
            ArticleMgmt["Article Management"]:::protected
        end

        subgraph Components["Components Layer"]
            UI["UI Components"]:::component
            ArticleComp["Article Components"]:::component
            ThemeComp["Theme Components"]:::component
            Nav["Navigation"]:::component
        end

        subgraph MiddlewareLayer["Middleware Layer"]
            AuthMW["Auth Middleware"]:::middleware
            SupabaseMW["Supabase Middleware"]:::middleware
        end

        subgraph Actions["Server Actions"]
            LoginAction["Login Actions"]:::action
            SignupAction["Signup Actions"]:::action
            ProtectedAction["Protected Actions"]:::action
        end
    end

    subgraph External["External Services"]
        Supabase["Supabase"]:::external
        AI["AI Service"]:::external
    end

    %% Connections
    Browser --> NextApp
    Browser --> PublicRoutes
    Browser --> ProtectedRoutes

    Login --> LoginAction
    Signup --> SignupAction
    MainApp --> ProtectedAction

    ProtectedRoutes --> AuthMW
    AuthMW --> Supabase
    SupabaseMW --> Supabase

    ArticleMgmt --> AI
    
    %% Component Relationships
    Components --> ProtectedRoutes
    Components --> PublicRoutes

    %% Click Events
    click Login "https://github.com/jcgentr/article-summarizer/blob/main/app/(public)/login/page.tsx"
    click Signup "https://github.com/jcgentr/article-summarizer/blob/main/app/(public)/signup/page.tsx"
    click Error "https://github.com/jcgentr/article-summarizer/blob/main/app/(public)/error/page.tsx"
    click MainApp "https://github.com/jcgentr/article-summarizer/blob/main/app/(protected)/page.tsx"
    click ArticleMgmt "https://github.com/jcgentr/article-summarizer/blob/main/components/ArticleList.tsx"
    click UI "https://github.com/jcgentr/article-summarizer/tree/main/components/ui/"
    click ThemeComp "https://github.com/jcgentr/article-summarizer/blob/main/components/ThemeProvider.tsx"
    click Nav "https://github.com/jcgentr/article-summarizer/blob/main/components/NavBar.tsx"
    click AuthMW "https://github.com/jcgentr/article-summarizer/blob/main/middleware.ts"
    click SupabaseMW "https://github.com/jcgentr/article-summarizer/blob/main/utils/supabase/middleware.ts"
    click LoginAction "https://github.com/jcgentr/article-summarizer/blob/main/app/(public)/login/actions.ts"
    click SignupAction "https://github.com/jcgentr/article-summarizer/blob/main/app/(public)/signup/actions.ts"
    click ProtectedAction "https://github.com/jcgentr/article-summarizer/blob/main/app/(protected)/actions.ts"
    click AI "https://github.com/jcgentr/article-summarizer/blob/main/lib/ai.ts"

    %% Styles
    classDef public fill:#6495ED
    classDef protected fill:#98FB98
    classDef component fill:#DDA0DD
    classDef middleware fill:#BA55D3
    classDef external fill:#FFA500
    classDef action fill:#20B2AA

    %% Legend
    subgraph Legend
        PublicL["Public Routes"]:::public
        ProtectedL["Protected Routes"]:::protected
        ComponentL["Components"]:::component
        MiddlewareL["Middleware"]:::middleware
        ExternalL["External Services"]:::external
        ActionL["Server Actions"]:::action
    end
```
