# whoisseth/ai-planner architecture

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

- Interactive diagram: https://gitdiagram.com/whoisseth/ai-planner
- Repository: https://github.com/whoisseth/ai-planner

## Overview

##### Project Type and Purpose
- It leverages modern architectural practices such as a tiered architecture, and uses technologies like Drizzle ORM, SQLite (or Turso), Arctic/Oslo for auth, and AWS SES for sending emails.

##### Analyzing the File Structure
- Notice several top-level configuration files (.env.sample, next.config.mjs, tailwind.config.ts, tsconfig.json) indicating the use of Next.js along with TypeScript and Tailwind CSS.
- The file tree splits the codebase into clear sections:
- “src/app” – Contains the Next.js App Router pages and grouped routes like “(auth)”, “(home)”, “dashboard”, etc.
- “src/api” – Includes API routes separated by concerns (chat, login, settings, etc.) which indicates clear back-end API endpoints.
- “src/db”, “migrations”, and “drizzle.config.ts” – Define the database schema and migration logic using Drizzle ORM.
- “src/data-access” and “src/use-cases” – Represent the business logic and data access layers.
- “src/lib” – Houses utility functions for authentication, emailing, session management, etc.
- “public” – Contains static assets like robots.txt, sitemap, sounds, etc.
- The presence of a “plan.md” and a “components.json” suggests documentation and possibly standardized UI components.

## Diagram (Mermaid)

```mermaid
graph TD
    %% User Interface Layer
    subgraph "User Interface Layer"
        FE["Frontend - Next.js Pages"]:::frontend
        UI1["UI Components - Components"]:::frontend
        UI2["UI Components - UI"]:::frontend
    end

    %% API/Server Layer
    subgraph "API/Server Layer"
        API["API Endpoints"]:::api
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        BL["Business Logic / Use Cases"]:::business
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        DA["Data Access Layer"]:::da
    end

    %% Database Layer
    subgraph "Database Layer"
        DRZ["Drizzle Config (drizzle.config.ts)"]:::database
        MIG["Migrations"]:::database
        DS["Database Schema (src/db)"]:::database
    end

    %% External Services & Utilities
    subgraph "External Services & Utilities"
        EXT1["Email Service"]:::external
        EXT2["Auth Service"]:::external
        UTIL["Utility / Library"]:::utility
    end

    %% Connections between layers
    FE -->|"calls"| API
    API -->|"delegates"| BL
    BL -->|"invokes"| DA
    DA -->|"uses"| DRZ
    DRZ -->|"manages"| MIG
    MIG -->|"applies_to"| DS
    BL -->|"email"| EXT1
    BL -->|"oauth"| EXT2
    FE -->|"uses"| UTIL
    API -->|"uses"| UTIL
    FE --- UI1
    FE --- UI2

    %% Legend
    subgraph "Legend"
        L1["Frontend - Next.js Pages (pink)"]:::frontend
        L2["API Endpoints (light blue)"]:::api
        L3["Business Logic / Use Cases (light green)"]:::business
        L4["Data Access Layer (light magenta)"]:::da
        L5["Database Layer (yellow)"]:::database
        L6["External Services (light cyan)"]:::external
        L7["Utility / Library (cyan)"]:::utility
    end

    %% Click Events
    click FE "https://github.com/whoisseth/ai-planner/tree/main/src/app"
    click UI1 "https://github.com/whoisseth/ai-planner/tree/main/src/components"
    click UI2 "https://github.com/whoisseth/ai-planner/tree/main/src/components/ui"
    click API "https://github.com/whoisseth/ai-planner/tree/main/src/app/api"
    click BL "https://github.com/whoisseth/ai-planner/tree/main/src/use-cases"
    click DA "https://github.com/whoisseth/ai-planner/tree/main/src/data-access"
    click DRZ "https://github.com/whoisseth/ai-planner/blob/main/drizzle.config.ts"
    click MIG "https://github.com/whoisseth/ai-planner/tree/main/migrations"
    click DS "https://github.com/whoisseth/ai-planner/tree/main/src/db"
    click EXT1 "https://github.com/whoisseth/ai-planner/blob/main/src/lib/email.tsx"
    click EXT2 "https://github.com/whoisseth/ai-planner/blob/main/src/lib/auth.ts"
    click UTIL "https://github.com/whoisseth/ai-planner/tree/main/src/lib"

    %% Styles
    classDef frontend fill:#ffccff,stroke:#333,stroke-width:2px;
    classDef api fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef business fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef da fill:#ffccff,stroke:#333,stroke-width:2px;
    classDef database fill:#ffffcc,stroke:#333,stroke-width:2px;
    classDef external fill:#ccffff,stroke:#333,stroke-width:2px;
    classDef utility fill:#cfffdc,stroke:#333,stroke-width:2px;
```
