# eniimz/cypress architecture

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

- Interactive diagram: https://gitdiagram.com/eniimz/cypress
- Repository: https://github.com/eniimz/cypress

## Overview

##### Main Components

A. Client-Side (Frontend):
- Next.js Application Layer
- Auth Routes (/auth)
- Main Dashboard Routes (/dashboard)
- Landing Page Routes (/site)
- Real-time Components
- UI Components Library (shadcn)

B. Server-Side:
- Next.js API Routes
- Socket.IO Server
- Authentication System
- Subscription Management

C. External Services:
- Supabase (Database & Authentication)
- Stripe (Payment Processing)

**[Client Tier]**
- ↕️
**[Application Tier]**
- ↕️
**[Data Tier]**

##### Client Tier
- Next.js pages structure
- Real-time collaboration components
- State management providers
- UI component library integration

##### Application Tier
- API routes handling
- Socket.IO server
- Server actions
- Authentication middleware
- Stripe integration

##### Data Tier
- Supabase database
- Drizzle ORM layer
- Real-time subscriptions
- File storage

- Blue: Frontend components
- Green: API/Backend services
- Yellow: External services
- Purple: Database and storage
- Red: Authentication flows
- Orange: Payment processing

Important Flows to Highlight:

##### Authentication Flow
- User → Auth Pages → Supabase Auth → Dashboard

##### Real-time Collaboration Flow
- User Action → Socket.IO → Other Users

##### Subscription Flow
- User → Stripe Checkout → Webhook → Database Update

Special Considerations:

##### Real-time Architecture
- Socket.IO connection between clients and server
- Supabase real-time subscriptions
- How real-time updates propagate through the system

##### File Structure
- Demonstrate the workspace/folder/file hierarchy
- How file permissions and sharing work
- Where file content is stored

##### State Management
- State providers (src/lib/providers)
- How state flows through the application
- Where real-time updates are managed

##### Security Layer
- Authentication boundaries
- Where middleware intercepts requests
- Permission checking points

Recommended Tools:
- Rectangles for services

Level of Detail:
- Keep high-level architecture clear and visible
- Use nested components to show detail where needed
- Annotations for critical paths and important notes

Remember to emphasize:

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        UI[UI Components]:::frontend
        click UI "https://github.com/Eniimz/cypress/tree/main/src/components/ui"
        Dashboard[Dashboard Interface]:::frontend
        click Dashboard "https://github.com/Eniimz/cypress/tree/main/src/app/(main)/dashboard"
        Landing[Landing Page]:::frontend
        click Landing "https://github.com/Eniimz/cypress/tree/main/src/app/(site)"
        Editor[File Editor]:::frontend
        click Editor "https://github.com/Eniimz/cypress/blob/main/src/components/quil-editor/QuilEditor.tsx"
        Workspace[Workspace Management]:::frontend
        click Workspace "https://github.com/Eniimz/cypress/tree/main/src/components/sidebar"
    end

    subgraph StateManagement
        StateProvider[State Provider]:::state
        click StateProvider "https://github.com/Eniimz/cypress/blob/main/src/lib/providers/state-provider.tsx"
        SocketProvider[Socket Provider]:::state
        click SocketProvider "https://github.com/Eniimz/cypress/blob/main/src/lib/providers/socket-providor.tsx"
        SupabaseProvider[Supabase Provider]:::state
        click SupabaseProvider "https://github.com/Eniimz/cypress/blob/main/src/lib/providers/supabaseUserProvider.tsx"
        SubModalProvider[Subscription Modal Provider]:::state
        click SubModalProvider "https://github.com/Eniimz/cypress/blob/main/src/lib/providers/subscription-modal-providor.tsx"
    end

    subgraph Server
        Auth[Authentication System]:::auth
        click Auth "https://github.com/Eniimz/cypress/tree/main/src/app/(auth)"
        APIRoutes[API Routes]:::api
        SocketIO[Socket.IO Server]:::realtime
        click SocketIO "https://github.com/Eniimz/cypress/blob/main/src/pages/api/socket/io.ts"
        StripeIntegration[Stripe Integration]:::payment
        click StripeIntegration "https://github.com/Eniimz/cypress/tree/main/src/lib/stripe"
    end

    subgraph ExternalServices
        Supabase[(Supabase DB)]:::database
        click Supabase "https://github.com/Eniimz/cypress/tree/main/src/lib/supabase"
        Stripe[Stripe Payment]:::payment
    end

    UI --> Dashboard
    UI --> Landing
    Dashboard --> Editor
    Dashboard --> Workspace

    StateProvider --> UI
    SocketProvider --> Editor
    SupabaseProvider --> Dashboard
    SubModalProvider --> Dashboard

    Auth --> APIRoutes
    APIRoutes --> SocketIO
    APIRoutes --> StripeIntegration

    SocketIO --> SocketProvider
    Auth --> Supabase
    StripeIntegration --> Stripe
    APIRoutes --> Supabase

    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef state fill:#9b59b6,stroke:#8e44ad,color:white
    classDef auth fill:#e74c3c,stroke:#c0392b,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef realtime fill:#f1c40f,stroke:#f39c12,color:white
    classDef payment fill:#e67e22,stroke:#d35400,color:white
    classDef database fill:#34495e,stroke:#2c3e50,color:white

    %% Legend
    subgraph Legend
        Frontend[Frontend]:::frontend
        State[State Management]:::state
        AuthComp[Authentication]:::auth
        ApiComp[API]:::api
        RealtimeComp[Realtime]:::realtime
        PaymentComp[Payment]:::payment
        DatabaseComp[Database]:::database
    end
```
