# noodle-run/noodle architecture

> Architecture diagram of the GitHub repository noodle-run/noodle, 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/noodle-run/noodle
- Repository: https://github.com/noodle-run/noodle

## Overview

##### Main System Components

a) Client Layer:
- Next.js Frontend (src/app directory structure indicates Next.js App Router)
- Split into two main sections:
- Public Site ((site) routes)
- Dashboard Application ((dashboard) routes)

b) API Layer:
- tRPC API (src/server/routers)
- API Routes (src/app/api)

c) Data Layer:
- Database (using Drizzle ORM)
- Redis Cache
- File Storage (for static assets)

d) External Services:
- Authentication (indicated by auth routes)
- Email Service (Resend - shown in src/emails)

##### Component Relationships

a) Frontend to Backend:
- tRPC client connections from dashboard to API
- API routes for public endpoints
- WebSocket connections for real-time features

b) Backend to Data:
- Database connections through Drizzle ORM
- Redis cache interactions
- Static file serving paths

##### Specific Implementation Details

Key architectural elements:

**[Client Layer]**
- Public Site
- Landing Page
- Blog System
- Legal Pages

- Dashboard
- Authentication
- Module Management
- Note Taking Interface

**[API Layer]**
- tRPC Routers
- Early Access
- Modules

- Middleware
- API Routes

**[Data Layer]**
- Database Schema
- Early Access
- Modules

- Redis Cache
- Static Assets

##### Future Extensibility

Placeholder sections for planned features:
- Calendar integration
- Task management system
- Grade tracking module
- Flashcard system

This structure reflects Noodle's nature as a modern, full-stack web application with a focus on student productivity features, while maintaining scalability and real-time capabilities.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Layer"]
        direction TB
        PublicSite["Public Site"]
        Dashboard["Dashboard Application"]
        
        subgraph PSections["Public Sections"]
            direction TB
            Landing["Landing Page"]
            Blog["Blog System"]
            Legal["Legal Pages"]
            EarlyAccess["Early Access"]
        end

        subgraph DSections["Dashboard Sections"]
            direction TB
            Auth["Authentication"]
            ModuleManagement["Module Management"]
            Notes["Note Taking Interface"]
        end

        PublicSite --> PSections
        Dashboard --> DSections
    end

    subgraph API["API Layer"]
        direction TB
        TRPC["tRPC API"]
        APIRoutes["API Routes"]
        TRPCRouters["tRPC Routers"]
        Middleware["Middleware"]
    end

    subgraph Data["Data Layer"]
        direction TB
        DB[(Database)]
        Redis[(Redis Cache)]
        Storage["Static Assets"]
    end

    subgraph External["External Services"]
        direction TB
        Auth_Service["Authentication Service"]
        Email["Email Service"]
    end

    %% Connections
    PublicSite --> APIRoutes
    Dashboard --> TRPC
    TRPC --> DB
    TRPC --> Redis
    APIRoutes --> DB
    Dashboard --> Auth_Service
    API --> Email

    %% Click Events
    click PublicSite "https://github.com/noodle-run/noodle/tree/main/src/app/(site)"
    click Dashboard "https://github.com/noodle-run/noodle/tree/main/src/app/(dashboard)/app"
    click Auth "https://github.com/noodle-run/noodle/tree/main/src/app/(dashboard)/(auth)"
    click TRPC "https://github.com/noodle-run/noodle/tree/main/src/server/routers"
    click APIRoutes "https://github.com/noodle-run/noodle/tree/main/src/app/api/trpc"
    click DB "https://github.com/noodle-run/noodle/tree/main/src/db/schema"
    click Redis "https://github.com/noodle-run/noodle/blob/main/src/lib/redis.ts"
    click Email "https://github.com/noodle-run/noodle/tree/main/src/emails"
    click ModuleManagement "https://github.com/noodle-run/noodle/tree/main/src/app/(dashboard)/app/module"
    click Blog "https://github.com/noodle-run/noodle/tree/main/src/app/(site)/blog"
    click EarlyAccess "https://github.com/noodle-run/noodle/tree/main/src/app/(site)/early-access"
    click Legal "https://github.com/noodle-run/noodle/tree/main/src/app/(site)/(legal)"

    %% Styling
    classDef frontend fill:#2196F3,stroke:#1565C0,color:white
    classDef backend fill:#4CAF50,stroke:#2E7D32,color:white
    classDef database fill:#FFC107,stroke:#FFA000,color:black
    classDef external fill:#9C27B0,stroke:#7B1FA2,color:white

    class PublicSite,Dashboard,PSections,DSections frontend
    class TRPC,APIRoutes,TRPCRouters,Middleware backend
    class DB,Redis,Storage database
    class Auth_Service,Email external

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Service"]:::backend
        DataStore["Data Storage"]:::database
        ExtService["External Service"]:::external
    end
```
