# desktoo/promptify architecture

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

- Interactive diagram: https://gitdiagram.com/desktoo/promptify
- Repository: https://github.com/desktoo/promptify

## Overview

##### Project type and purpose
- From the file tree and README, this is a Next.js 13 “app”-directory full-stack web application.
- It provides user authentication (via NextAuth), CRUD operations on “prompts,” and user profiles.
- Tech stack: React (server- and client-components), Next.js API routes, Tailwind CSS, NextAuth, MongoDB (or a similar document store), deployed on Vercel.

##### File structure
- Top-level:
· app/ — React pages and server-component routing (app/api for backend endpoints)
· components/ — reusable React UI components
· models/ — Mongoose (or similar) schema definitions for Prompt and User
· utils/database.js — database connection helper
· assets/, styles/ — static assets and global CSS
· next.config.mjs, jsconfig.json, tailwind.config.js — build and path configs
- Under app/:
· app/layout.jsx, app/page.jsx — global layout and homepage
· app/create-prompt, app/update-prompt, app/profile — client pages
· app/api/auth/[...nextauth]/route.js — NextAuth authentication routes
· app/api/prompt/... — CRUD API endpoints
· app/api/users/[id]/posts — nested user posts route

##### README
- Confirms it’s a Next.js project bootstrapped with create-next-app
- Mentions usage of next/font and deployment on Vercel

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Browser Tier
    subgraph "Browser (Client)" 
        direction TB
        Nav["Navigation Bar"]:::ui
        Feed["Feed Component"]:::ui
        Form["Form Component"]:::ui
        PromptCard["Prompt Card"]:::ui
        ProfileCard["User Profile Card"]:::ui
        EditPrompt["Edit Prompt Form"]:::ui
        Provider["Authentication Provider Wrapper"]:::ui
    end

    %% CDN Tier
    subgraph "Vercel CDN / Static Assets"
        assets["Static Assets (Images/Icons/Fonts)"]:::third
    end

    %% Next.js Server Tier
    subgraph "Next.js Server"
        direction TB
        Rendering["Rendering Engine (SSR/SSG)"]:::server
        subgraph "Page Routes"
            direction TB
            Layout["Global Layout & Metadata"]:::server
            HomePage["Home Page / Feed"]:::server
            CreatePage["Create New Prompt Page"]:::server
            UpdatePage["Update Prompt Page"]:::server
            ProfilePage["User Profile Page"]:::server
        end
        subgraph "API Layer"
            direction TB
            AuthAPI["NextAuth Routes"]:::api
            PromptAPI["Prompt List/Create Endpoint"]:::api
            PromptIDAPI["Prompt Fetch/Update/Delete Endpoint"]:::api
            PromptNewAPI["Prompt New Endpoint"]:::api
            UserPostsAPI["User Posts Endpoint"]:::api
        end
        DBUtil["MongoDB Connection Helper"]:::server
        subgraph "Data Models"
            PromptModel["Prompt Schema"]:::dbutil
            UserModel["User Schema"]:::dbutil
        end
    end

    %% Third-Party Tier
    subgraph "Third-Party OAuth Providers"
        OAuth["OAuth Providers (GitHub, Google)"]:::third
    end

    %% Database Tier
    subgraph "Database (MongoDB)"
        DB["MongoDB Cluster"]:::db
    end

    %% Relationships
    assets -.->|served to| Nav
    assets -.->|served to| Feed
    Nav -->|navigates to| HomePage
    HomePage -->|renders via| Rendering
    CreatePage -->|renders via| Rendering
    UpdatePage -->|renders via| Rendering
    ProfilePage -->|renders via| Rendering

    Provider -->|wraps| AuthAPI
    Feed -->|fetch prompts via| PromptAPI
    Form -->|create prompt via| PromptAPI
    EditPrompt -->|update/delete via| PromptIDAPI
    ProfileCard -->|fetch user posts via| UserPostsAPI

    Rendering -->|fetch/write| DBUtil
    AuthAPI -->|uses| DBUtil
    PromptAPI -->|uses| DBUtil
    PromptIDAPI -->|uses| DBUtil
    PromptNewAPI -->|uses| DBUtil
    UserPostsAPI -->|uses| DBUtil

    DBUtil -->|defines schema| PromptModel
    DBUtil -->|defines schema| UserModel
    PromptModel -->|storage| DB
    UserModel -->|storage| DB
    AuthAPI -->|auth flow| OAuth
    OAuth -->|callback| AuthAPI
    AuthAPI -->|session storage| DB

    assets -->|CDN| assets

    %% Click Events
    click Nav "https://github.com/desktoo/promptify/blob/main/components/Nav.jsx"
    click Feed "https://github.com/desktoo/promptify/blob/main/components/Feed.jsx"
    click Form "https://github.com/desktoo/promptify/blob/main/components/Form.jsx"
    click PromptCard "https://github.com/desktoo/promptify/blob/main/components/PromptCard.jsx"
    click ProfileCard "https://github.com/desktoo/promptify/blob/main/components/Profile.jsx"
    click EditPrompt "https://github.com/desktoo/promptify/blob/main/components/EditPrompt.jsx"
    click Provider "https://github.com/desktoo/promptify/blob/main/components/Provider.jsx"

    click Layout "https://github.com/desktoo/promptify/blob/main/app/layout.jsx"
    click HomePage "https://github.com/desktoo/promptify/blob/main/app/page.jsx"
    click CreatePage "https://github.com/desktoo/promptify/blob/main/app/create-prompt/page.jsx"
    click UpdatePage "https://github.com/desktoo/promptify/blob/main/app/update-prompt/page.jsx"
    click ProfilePage "https://github.com/desktoo/promptify/blob/main/app/profile/page.jsx"

    click AuthAPI "https://github.com/desktoo/promptify/blob/main/app/api/auth/[...nextauth]/route.js"
    click PromptAPI "https://github.com/desktoo/promptify/blob/main/app/api/prompt/route.js"
    click PromptIDAPI "https://github.com/desktoo/promptify/blob/main/app/api/prompt/[id]/route.js"
    click PromptNewAPI "https://github.com/desktoo/promptify/blob/main/app/api/prompt/new/route.js"
    click UserPostsAPI "https://github.com/desktoo/promptify/blob/main/app/api/users/[id]/posts/route.js"

    click PromptModel "https://github.com/desktoo/promptify/blob/main/models/prompt.js"
    click UserModel "https://github.com/desktoo/promptify/blob/main/models/user.js"
    click DBUtil "https://github.com/desktoo/promptify/blob/main/utils/database.js"
    click assets "https://github.com/desktoo/promptify/tree/main/assets/icons/"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#3A7CA5,color:#034078
    classDef server fill:#DFF3E3,stroke:#3A6B35,color:#174A0F
    classDef api fill:#E8F0FE,stroke:#3B5998,color:#1E3A8A
    classDef dbutil fill:#FFF4E6,stroke:#CC8E35,color:#7A4219
    classDef db fill:#FFEFEF,stroke:#C53030,color:#721C24
    classDef third fill:#F0F0F0,stroke:#888888,color:#555555
```
