# dr-octocodius/mono-app architecture

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

- Interactive diagram: https://gitdiagram.com/dr-octocodius/mono-app
- Repository: https://github.com/dr-octocodius/mono-app

## Overview

##### Main Components

a. Client-Side Layer:
- Next.js Frontend (App Router)
- Components Structure
- Auth components
- Editor components
- Global components
- UI components
- Posts components
- User components

b. Server-Side Layer:
- Next.js Server Components
- Server Actions
- API Routes
- Middleware

c. External Services:
- Supabase
- Authentication
- Database
- API

**┌─ Client Layer ─────────────────────┐**
- Next.js App Router              │
- React Components                │
- Client-side Hooks               │
- ┬───────────────────┘

**┌─ Server Layer ─┴───────────────────┐**
- Server Components               │
- API Routes                      │
- Middleware                      │
- Server Actions                  │
- ┬───────────────────┘

**┌─ Supabase ─────┴───────────────────┐**
- Authentication                  │
- Database                        │
- Real-time subscriptions         │
- ┘

##### Key Relationships to Highlight

- Authentication flow between client, server, and Supabase
- Demonstrate data flow for posts and comments
- Role of middleware in request handling
- How server actions interact with Supabase

##### Implementation Details

Use these specific project elements:
- App/(routes) structure
- Auth flow through app/auth
- Demonstrate how components/posts connects to the backend
- Utils/supabase integration points

##### Additional Elements

- Notes about environment configuration
- Deployment flow to Vercel
- Where Tailwind CSS fits in the styling layer

##### Technical Specifications

Key technical aspects:
- Next.js App Router architecture
- Supabase-ssr cookie-based auth
- Server Components vs Client Components
- API routes and middleware interaction

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        AppRouter["Next.js App Router"]
        
        subgraph Components
            AuthComp["Auth Components"]
            EditorComp["Editor Components"]
            GlobalComp["Global Components"]
            UIComp["UI Components"]
            PostsComp["Posts Components"]
            UserComp["User Components"]
        end
        
        subgraph ClientHooks
            BookmarkHook["useBookmark"]
            LikesHook["useLikes"]
            UserHook["useUserClient"]
            DeleteHook["useDelete"]
        end
        
        subgraph Routes
            NewPost["New Post"]
            PostView["Post View"]
            MyPosts["My Posts"]
            ReadingList["Reading List"]
        end
    end
    
    subgraph Server
        ServerComponents["Server Components"]
        ServerActions["Server Actions"]
        APIRoutes["API Routes"]
        Middleware["Middleware"]
    end
    
    subgraph Supabase
        SupabaseAuth["Authentication"]
        SupabaseDB["Database"]
        SupabaseRealtime["Real-time Subscriptions"]
        SupabaseTypes["Database Types"]
    end
    
    %% Relationships
    AppRouter --> ServerComponents
    Components --> ServerComponents
    ClientHooks --> ServerActions
    ServerComponents --> SupabaseDB
    ServerActions --> SupabaseDB
    APIRoutes --> SupabaseAuth
    Middleware --> SupabaseAuth
    
    %% Click Events
    click AppRouter "https://github.com/dr-octocodius/mono-app/tree/master/app/(routes)/"
    click AuthComp "https://github.com/dr-octocodius/mono-app/tree/master/components/auth/"
    click EditorComp "https://github.com/dr-octocodius/mono-app/tree/master/components/editor/"
    click GlobalComp "https://github.com/dr-octocodius/mono-app/tree/master/components/global/"
    click UIComp "https://github.com/dr-octocodius/mono-app/tree/master/components/ui/"
    click PostsComp "https://github.com/dr-octocodius/mono-app/tree/master/components/posts/"
    click UserComp "https://github.com/dr-octocodius/mono-app/tree/master/components/user/"
    click BookmarkHook "https://github.com/dr-octocodius/mono-app/blob/master/utils/hooks/useBookmark.tsx"
    click LikesHook "https://github.com/dr-octocodius/mono-app/blob/master/utils/hooks/useLikes.tsx"
    click UserHook "https://github.com/dr-octocodius/mono-app/blob/master/utils/hooks/useUserClient.tsx"
    click DeleteHook "https://github.com/dr-octocodius/mono-app/blob/master/utils/hooks/useDelete.tsx"
    click ServerActions "https://github.com/dr-octocodius/mono-app/blob/master/utils/server/actions.ts"
    click Middleware "https://github.com/dr-octocodius/mono-app/blob/master/middleware.ts"
    click APIRoutes "https://github.com/dr-octocodius/mono-app/blob/master/app/auth/confirm/route.ts"
    click SupabaseAuth "https://github.com/dr-octocodius/mono-app/blob/master/utils/supabase/server.ts"
    click SupabaseTypes "https://github.com/dr-octocodius/mono-app/blob/master/utils/supabase/database.types.ts"
    click NewPost "https://github.com/dr-octocodius/mono-app/tree/master/app/(routes)/post/new/"
    click PostView "https://github.com/dr-octocodius/mono-app/tree/master/app/(routes)/post/[slug]/"
    click MyPosts "https://github.com/dr-octocodius/mono-app/tree/master/app/(routes)/my_posts/"
    click ReadingList "https://github.com/dr-octocodius/mono-app/tree/master/app/(routes)/reading_list/"
    
    %% Styling
    classDef client fill:#a8dadc
    classDef server fill:#457b9d
    classDef supabase fill:#e63946
    classDef component fill:#f1faee
    classDef route fill:#1d3557
    
    class AppRouter,Components,ClientHooks,Routes client
    class ServerComponents,ServerActions,APIRoutes,Middleware server
    class SupabaseAuth,SupabaseDB,SupabaseRealtime,SupabaseTypes supabase
    class AuthComp,EditorComp,GlobalComp,UIComp,PostsComp,UserComp component
    class NewPost,PostView,MyPosts,ReadingList route
```
