# realfascinated/paste architecture

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

- Interactive diagram: https://gitdiagram.com/realfascinated/paste
- Repository: https://github.com/realfascinated/paste

## Overview

##### Main Components

a. Frontend Layer:
- Next.js Application (Client-side)
- Pages/Routes structure (/app directory)
- Components hierarchy
- UI Components
- Providers (QueryProvider, PasteExpiryProvider)

b. Backend Layer:
- API Routes (/api directory)
- Authentication System
- Rate Limiting Service
- Filter System
- Database Layer (Prisma ORM)

##### Key Architectural Elements

**Client Layer**
- Public Routes
- Authentication Pages
- Paste View
- Dashboard

**Middleware Layer**
- Rate Limiting
- Authentication
- Request Filtering

**API Layer**
- Auth Routes
- Paste Management
- User Management
- Upload Handling

**Data Layer**
- Prisma ORM
- Database

##### Component Relationships

- Client-to-API communication
- Authentication flow
- Data flow between components
- Integration points with external services

##### Technical Details to Highlight

- Next.js App Router architecture
- API route structure
- Database migrations
- Authentication implementation
- Rate limiting mechanism
- Content filtering system

##### Implementation Notes

- The separation between public and authenticated routes
- The role of middleware in request processing
- How the paste service handles different types of requests
- Integration of syntax highlighting and paste expiration
- User dashboard functionality
- Security measures (rate limiting, filtering)

##### Additional Elements

Annotations for:
- Environment configuration
- Docker deployment structure
- Database migration flow
- API endpoints and their purposes

This system design should reflect the modern web application architecture while highlighting the specific features of the paste service, such as syntax highlighting, paste expiration, and content filtering.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        FE[Frontend Application]
        Pages["Pages/Routes"]
        UI["UI Components"]
        Auth["Authentication Components"]
        PasteMgmt["Paste Management UI"]
        SyntaxHL["Syntax Highlighter"]
        DashUI["Dashboard Interface"]
        Providers["Application Providers"]
        PasteExp["Paste Expiry Provider"]
    end

    subgraph Middleware
        RateLimit["Rate Limiting Service"]
        AuthMW["Authentication Middleware"]
        Filter["Content Filter System"]
        FilterImpl["Filter Implementation"]
    end

    subgraph "API Layer"
        AuthAPI["Authentication API"]
        PasteAPI["Paste API"]
        UserAPI["User Management API"]
    end

    subgraph "Data Layer"
        Prisma["Prisma ORM"]
        DB[(Database)]
        Migrations["Database Migrations"]
    end

    subgraph "Common"
        Utils["Utilities"]
        Types["Type Definitions"]
    end

    %% Relationships
    FE --> Pages
    FE --> UI
    FE --> Auth
    FE --> PasteMgmt
    FE --> SyntaxHL
    FE --> DashUI
    FE --> Providers
    Providers --> PasteExp

    Pages --> AuthAPI
    Pages --> PasteAPI
    Pages --> UserAPI

    AuthAPI --> AuthMW
    PasteAPI --> RateLimit
    PasteAPI --> Filter
    Filter --> FilterImpl

    AuthAPI --> Prisma
    PasteAPI --> Prisma
    UserAPI --> Prisma
    Prisma --> DB
    Prisma --> Migrations

    AuthMW --> Utils
    RateLimit --> Utils
    Filter --> Utils
    Utils --> Types

    %% Click Events
    click Pages "https://github.com/RealFascinated/Paste/tree/master/src/app/(pages)"
    click UI "https://github.com/RealFascinated/Paste/tree/master/src/components/ui"
    click Providers "https://github.com/RealFascinated/Paste/tree/master/src/providers"
    click Auth "https://github.com/RealFascinated/Paste/tree/master/src/components/auth"
    click AuthAPI "https://github.com/RealFascinated/Paste/tree/master/src/app/api/auth"
    click AuthMW "https://github.com/RealFascinated/Paste/blob/master/src/common/auth.ts"
    click RateLimit "https://github.com/RealFascinated/Paste/blob/master/src/common/ratelimiter.ts"
    click Filter "https://github.com/RealFascinated/Paste/tree/master/src/filter"
    click Prisma "https://github.com/RealFascinated/Paste/blob/master/schema.prisma"
    click PasteMgmt "https://github.com/RealFascinated/Paste/tree/master/src/components/paste"
    click SyntaxHL "https://github.com/RealFascinated/Paste/blob/master/src/components/highlighter.tsx"
    click PasteExp "https://github.com/RealFascinated/Paste/blob/master/src/providers/paste-expiry-provider.tsx"
    click DashUI "https://github.com/RealFascinated/Paste/tree/master/src/components/dashboard"
    click UserAPI "https://github.com/RealFascinated/Paste/tree/master/src/app/api/user"
    click PasteAPI "https://github.com/RealFascinated/Paste/tree/master/src/app/api/paste"
    click Migrations "https://github.com/RealFascinated/Paste/tree/master/migrations"
    click FilterImpl "https://github.com/RealFascinated/Paste/tree/master/src/filter/impl"
    click Utils "https://github.com/RealFascinated/Paste/tree/master/src/common/utils"
    click Types "https://github.com/RealFascinated/Paste/tree/master/src/types"

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef middleware fill:#f1c40f,stroke:#f39c12,color:black
    classDef database fill:#9b59b6,stroke:#8e44ad,color:white
    classDef common fill:#e74c3c,stroke:#c0392b,color:white

    class FE,Pages,UI,Auth,PasteMgmt,SyntaxHL,DashUI,Providers,PasteExp frontend
    class AuthAPI,PasteAPI,UserAPI api
    class RateLimit,AuthMW,Filter,FilterImpl middleware
    class Prisma,DB,Migrations database
    class Utils,Types common
```
