# learnathon-by-geeky-solutions/xtradrill architecture

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

- Interactive diagram: https://gitdiagram.com/learnathon-by-geeky-solutions/xtradrill
- Repository: https://github.com/learnathon-by-geeky-solutions/xtradrill

## Overview

##### Main System Components

a) Client-Side (Frontend):
- Next.js Application Layer
- Authentication Components (Clerk integration)
- Dashboard Interface
- Landing Page
- Client-side Layout Components

b) Server-Side:
- API Routes Layer
- Webhook Handlers
- MongoDB Database Layer
- Authentication Service (Clerk)

**┌─ Client Layer ─────────────────┐**
- ┌─ Pages ──┐ ┌─ Components ─┐ │
- Landing  │ │ Header      │ │
- Dashboard│ │ Sidebar     │ │    ┌─ External Services ─┐
- Auth     │ │ Layout      │ │    │     Clerk Auth     │
- ┘ └─────────────┘ │    └──────────┬─────────┘

- API Layer ─────────────────┤               │
- ┌─ Routes ─┐ ┌─ Webhooks ─┐ │◄──────────────┘
- /api     │ │ /clerk     │ │
- ┘ └───────────┬─┘ │

- Server Layer ──────────┼────┤
- ┌─ Actions ─┐          │    │
- User      │◄─────────┘    │
- ┬──────┘               │

- ┌────▼──────┐              │
- Models   │              │
- ┬──────┘              │

- ┌────▼──────┐              │
- MongoDB   │              │
- ┘              │
- ┘

##### Key Relationships to Highlight

a) Authentication Flow:
- How sign-in/sign-up pages connect to Clerk
- Webhook integration from Clerk to your API
- Demonstrate user data flow to MongoDB

b) Application Structure:
- Relationship between pages and components
- API routes and their connection to actions
- Database model relationships

##### Important Implementation Details

Technical aspects:
- Next.js 13+ App Router structure
- API routes under app/api
- MongoDB connection through mongoose
- Clerk authentication integration
- Server actions in lib/actions

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Landing["Landing Page"]
        Dashboard["Dashboard"]
        Auth["Authentication Pages"]
        
        subgraph Components
            Header["Header Component"]
            Sidebar["Sidebar Component"]
            Layout["Client Layout"]
        end
    end

    subgraph APILayer
        API["API Routes"]
        Webhook["Clerk Webhook Handler"]
    end

    subgraph ServerLayer
        Actions["Server Actions"]
        Models["Database Models"]
        MongoDB[(MongoDB Database)]
        Middleware["Auth Middleware"]
    end

    subgraph ExternalServices
        Clerk["Clerk Authentication"]
    end

    %% Relationships
    Landing --> Layout
    Dashboard --> Layout
    Auth --> Layout
    Layout --> Header
    Layout --> Sidebar
    
    Auth <--> Clerk
    Clerk --> Webhook
    Webhook --> Actions
    Actions --> Models
    Models --> MongoDB
    
    API --> Actions
    Middleware --> Clerk

    %% Styling
    classDef client fill:#a8d1ff,stroke:#333,stroke-width:1px
    classDef server fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#FFE5B4,stroke:#333,stroke-width:1px
    classDef database fill:#ff9999,stroke:#333,stroke-width:1px
    
    class Landing,Dashboard,Auth,Header,Sidebar,Layout client
    class API,Webhook,Actions,Models,Middleware server
    class Clerk external
    class MongoDB database

    %% Click Events
    click Landing "https://github.com/Learnathon-By-Geeky-Solutions/xtradrill/blob/main/app/components/LandingPage.jsx"
    click Dashboard "https://github.com/Learnathon-By-Geeky-Solutions/xtradrill/blob/main/app/dashboard/page.jsx"
    click Layout "https://github.com/Learnathon-By-Geeky-Solutions/xtradrill/blob/main/app/components/ClientLayout.jsx"
    click Header "https://github.com/Learnathon-By-Geeky-Solutions/xtradrill/blob/main/app/components/Header.jsx"
    click Sidebar "https://github.com/Learnathon-By-Geeky-Solutions/xtradrill/blob/main/app/components/Sidebar.jsx"
    click Auth "https://github.com/Learnathon-By-Geeky-Solutions/xtradrill/blob/main/app/sign-in/[[...sign-in]]/page.jsx"
    click Webhook "https://github.com/Learnathon-By-Geeky-Solutions/xtradrill/blob/main/app/api/webhooks/clerk/route.js"
    click MongoDB "https://github.com/Learnathon-By-Geeky-Solutions/xtradrill/blob/main/lib/mongodb/mongoose.js"
    click Models "https://github.com/Learnathon-By-Geeky-Solutions/xtradrill/blob/main/lib/models/userModel.js"
    click Actions "https://github.com/Learnathon-By-Geeky-Solutions/xtradrill/blob/main/lib/actions/user.js"
    click Middleware "https://github.com/Learnathon-By-Geeky-Solutions/xtradrill/blob/main/middleware.js"
```
