# akasha1618/prompt-craft-studio architecture

> Architecture diagram of the GitHub repository akasha1618/prompt-craft-studio, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/akasha1618/prompt-craft-studio
- Repository: https://github.com/akasha1618/prompt-craft-studio

## Overview

##### Project type and purpose
- This is a full-stack, serverless Next.js 14 application ("PromptCraft Studio") for end-to-end LLM prompt engineering (creation, chaining, improvement/optimization, testing, analytics) built on TypeScript, Tailwind CSS, Supabase (Auth + PostgreSQL + RLS) and integrating external AI providers (OpenAI, Anthropic).

##### File structure
- Top-level “app/” folder uses Next.js App Router:
- app/api/… → serverless API routes for prompt operations (generate, improve, optimize, test, user-settings)
- app/auth/… → auth flows (signup, login, reset, callback)
- app/dashboard/… → UI pages for chains, prompts, tests, settings
- app/layout.tsx, app/globals.css → global layout + styling
- Config files: next.config.js, tsconfig.json, tailwind.config.js
- types/database.ts defines Supabase-related types
- README describes Supabase schema (supabase/schema.sql) and deployment guides

##### README for architectural insights
- Backend: Supabase for Auth & Postgres (with RLS), Next.js API routes as the server layer for AI calls
- AI Integration: external HTTP calls to OpenAI & Anthropic APIs
- Deployment: Vercel (serverless) or manual Node server

##### Detail without overthinking
- Every major route and flow (prompt creation, chaining, testing, settings)
- RLS security guard at the DB level
- How a new prompt flows from Browser → Next.js API → Supabase → AI → DB → Browser
- Multi-model branching when testing or chaining

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    Browser["Browser (SPA)"]:::client

    subgraph "Client/UI Layer"
        subgraph "Global"
            Layout["Global Layout & Styling"]:::ui
            Home["Home Page"]:::ui
        end
        subgraph "Auth UI"
            Signup["Signup Page"]:::ui
            Login["Login Page"]:::ui
            Reset["Reset Password Page"]:::ui
            OAuthRoute["OAuth Callback Route"]:::ui
            OAuthPage["OAuth Callback Page"]:::ui
        end
        subgraph "Dashboard UI"
            DashRoot["Dashboard Home"]:::ui
            ChainsList["Chains Listing"]:::ui
            ChainsHistory["Chains History"]:::ui
            CreatePage["Create Chain Page"]:::ui
            EnhancePage["Enhance Chain Page"]:::ui
            LabPage["Lab Page"]:::ui
            PromptsList["List Prompts"]:::ui
            PromptView["View Prompt"]:::ui
            PromptEdit["Edit Prompt"]:::ui
            PromptImprove["Improve Prompt"]:::ui
            PromptOptimize["Optimize Prompt"]:::ui
            TestUI["Test UI"]:::ui
            SettingsUI["User Settings UI"]:::ui
        end
    end

    %% API Layer
    subgraph "API Layer"
        GenChain["Generate Prompt Chain API"]:::api
        GenPrompt["Generate Single Prompt API"]:::api
        Improve["Improve Prompt API"]:::api
        Optimize["Optimize Prompt API"]:::api
        TestChain["Test Prompt Chain API"]:::api
        TestPrompt["Test Single Prompt API"]:::api
        UserSettingsAPI["User Settings API"]:::api
    end

    %% Data Layer
    subgraph "Data Layer"
        SupaAuth["Supabase Auth Service"]:::db
        SupaDB["Supabase PostgreSQL (with RLS)"]:::db
    end

    %% External Services
    subgraph "External AI Services"
        OpenAI["OpenAI API"]:::external
        Anthropic["Anthropic API"]:::external
    end

    %% Deployment
    subgraph "Deployment"
        Vercel["Vercel (CI/CD & Hosting)"]:::deploy
    end

    %% Connections
    Browser -->|navigates| Home
    Browser -->|navigates| Signup
    Browser -->|navigates| Login
    Browser -->|navigates| Reset
    Browser -->|navigates| OAuthPage
    Browser -->|navigates| DashRoot

    Home -->|fetch/AJAX| GenPrompt
    Signup -->|submit| UserSettingsAPI
    Login -->|submit| UserSettingsAPI
    Reset -->|submit| UserSettingsAPI
    OAuthPage -->|callback| UserSettingsAPI

    DashRoot -->|fetch| GenChain
    ChainsList -->|fetch| GenChain
    ChainsHistory -->|fetch| TestChain
    CreatePage -->|submit| GenChain
    EnhancePage -->|submit| Improve
    LabPage -->|submit| Optimize
    PromptsList -->|fetch| GenPrompt
    PromptView -->|fetch| GenPrompt
    PromptEdit -->|submit| GenPrompt
    PromptImprove -->|submit| Improve
    PromptOptimize -->|submit| Optimize
    TestUI -->|submit| TestPrompt
    SettingsUI -->|fetch/update| UserSettingsAPI

    %% API to Data
    GenChain -->|auth jwt| SupaAuth
    GenPrompt -->|auth jwt| SupaAuth
    Improve -->|auth jwt| SupaAuth
    Optimize -->|auth jwt| SupaAuth
    TestChain -->|auth jwt| SupaAuth
    TestPrompt -->|auth jwt| SupaAuth
    UserSettingsAPI -->|auth jwt| SupaAuth

    GenChain -->|CRUD| SupaDB
    GenPrompt -->|CRUD| SupaDB
    Improve -->|CRUD| SupaDB
    Optimize -->|CRUD| SupaDB
    TestChain -->|CRUD| SupaDB
    TestPrompt -->|CRUD| SupaDB
    UserSettingsAPI -->|CRUD| SupaDB

    %% API to External
    GenChain -->|HTTP| OpenAI
    GenPrompt -->|HTTP| OpenAI
    Improve -->|HTTP| OpenAI
    Optimize -->|HTTP| OpenAI
    TestChain -->|HTTP| Anthropic
    TestPrompt -->|HTTP| Anthropic

    OpenAI -->|response| GenChain
    OpenAI -->|response| GenPrompt
    OpenAI -->|response| Improve
    OpenAI -->|response| Optimize
    Anthropic -->|response| TestChain
    Anthropic -->|response| TestPrompt

    %% Deployment
    Vercel -->|deploy| Browser
    Vercel -->|deploy| GenChain
    Vercel -->|deploy| GenPrompt
    Vercel -->|deploy| Improve
    Vercel -->|deploy| Optimize
    Vercel -->|deploy| TestChain
    Vercel -->|deploy| TestPrompt
    Vercel -->|deploy| UserSettingsAPI

    %% Click Events
    click Layout "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/layout.tsx"
    click Layout "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/globals.css"
    click Home "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/page.tsx"
    click Signup "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/auth/signup/page.tsx"
    click Login "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/auth/login/page.tsx"
    click Reset "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/auth/reset-password/page.tsx"
    click OAuthRoute "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/auth/callback/route.ts"
    click OAuthPage "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/auth/callback/page.tsx"
    click DashRoot "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/dashboard/page.tsx"
    click DashRoot "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/dashboard/layout.tsx"
    click ChainsList "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/dashboard/chains/page.tsx"
    click ChainsHistory "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/dashboard/chains/history/page.tsx"
    click CreatePage "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/dashboard/create/page.tsx"
    click EnhancePage "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/dashboard/enhance/page.tsx"
    click LabPage "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/dashboard/lab/page.tsx"
    click PromptsList "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/dashboard/prompts/page.tsx"
    click PromptView "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/dashboard/prompts/[id]/page.tsx"
    click PromptEdit "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/dashboard/prompts/[id]/edit/page.tsx"
    click PromptImprove "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/dashboard/prompts/[id]/improve/page.tsx"
    click PromptOptimize "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/dashboard/prompts/[id]/optimize/page.tsx"
    click TestUI "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/dashboard/test/page.tsx"
    click SettingsUI "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/dashboard/settings/page.tsx"
    click GenChain "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/api/generate-prompt-chain/route.ts"
    click GenPrompt "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/api/generate-prompt/route.ts"
    click Improve "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/api/improve-prompt/route.ts"
    click Optimize "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/api/optimize-prompt/route.ts"
    click TestChain "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/api/test-prompt-chain/route.ts"
    click TestPrompt "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/api/test-prompt/route.ts"
    click UserSettingsAPI "https://github.com/akasha1618/prompt-craft-studio/blob/main/app/api/user-settings/route.ts"

    %% Styles
    classDef ui fill:#cbdefe,stroke:#0366d6,stroke-width:1px
    classDef api fill:#d2f8d2,stroke:#028a02,stroke-width:1px
    classDef db fill:#ffe0b2,stroke:#e65100,stroke-width:1px
    classDef external fill:#e1bee7,stroke:#6a1b9a,stroke-width:1px
    classDef deploy fill:#c8e6c9,stroke:#2e7d32,stroke-width:1px
    classDef client fill:#bbdefb,stroke:#0d47a1,stroke-width:1px
```
