# sanju1098/prompt-stack architecture

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

- Interactive diagram: https://gitdiagram.com/sanju1098/prompt-stack
- Repository: https://github.com/sanju1098/prompt-stack

## Overview

PromptStack is a prompt library and live-testing workspace. Users browse and search saved prompts, create or edit reusable templates, inspect details, then run a prompt with supplied variables against Gemini or Groq; curated marketplace templates can also be forked into the library. The graph covers the dashboard, detail/playground and marketplace routes, server actions, parsing, persistence, and analytics. Some route and integration links follow explicit README capabilities because their implementation was not sampled; these are marked dashed where source evidence is unavailable.

Main entry points: [`src/app/actions/promptActions.ts`](https://github.com/sanju1098/prompt-stack/blob/master/src/app/actions/promptActions.ts) (Prompt actions), [`src/app/actions/templateActions.ts`](https://github.com/sanju1098/prompt-stack/blob/master/src/app/actions/templateActions.ts) (Template actions), [`src/app/page.tsx`](https://github.com/sanju1098/prompt-stack/blob/master/src/app/page.tsx) (Prompt dashboard), [`src/app/[id]/prompt/page.tsx`](https://github.com/sanju1098/prompt-stack/blob/master/src/app/%5Bid%5D/prompt/page.tsx) (Prompt details)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Prompt workspace"]
  node_dashboard["Prompt dashboard<br/>[page.tsx]"]
  node_promptform["Prompt editor"]
  node_promptdetail["Prompt details<br/>[page.tsx]"]
  node_snippet["Integration snippets<br/>[codeSnippet.tsx]"]
end

subgraph group_market["Template marketplace"]
  node_templateform["Template editor"]
  node_marketplace["Marketplace browser<br/>[Template.tsx]"]
  node_templatedetail["Template details<br/>[page.tsx]"]
end

subgraph group_runtime["Prompt runtime"]
  node_playground["Live playground<br/>[Playground.tsx]"]
  node_parser["Variable parser<br/>[parser.ts]"]
end

subgraph group_data["Persistence and services"]
  node_promptactions["Prompt actions<br/>[promptActions.ts]"]
  node_templateactions["Template actions<br/>[templateActions.ts]"]
  node_statsactions["Workspace statistics<br/>[statsActions.ts]"]
  node_promptmodel["Prompt schema<br/>[Prompt.ts]"]
  node_templatemodel["Template schema<br/>[Templates.ts]"]
  node_database["MongoDB connection<br/>[database.ts]"]
end

node_user(("Workspace user"))
node_mongodb[("MongoDB")]
node_gemini{{"Gemini API"}}
node_groq{{"Groq API"}}

node_user -->|"browses prompts"| node_dashboard
node_dashboard -->|"searches prompts"| node_promptactions
node_dashboard -->|"loads stats"| node_statsactions
node_user -->|"creates or edits"| node_promptform
node_promptform -->|"saves prompt"| node_promptactions
node_dashboard -->|"opens details"| node_promptdetail
node_promptdetail -->|"loads prompt"| node_promptactions
node_promptdetail -->|"shows examples"| node_snippet
node_promptdetail -->|"opens testing"| node_playground
node_user -->|"tests prompt"| node_playground
node_playground -->|"executes prompt"| node_promptactions
node_promptactions -->|"hydrates variables"| node_parser
node_promptactions -->|"generates content"| node_gemini
node_promptactions -->|"generates completion"| node_groq
node_user -->|"browses templates"| node_marketplace
node_marketplace -->|"loads templates"| node_templateactions
node_user -->|"publishes template"| node_templateform
node_templateform -->|"creates template"| node_templateactions
node_marketplace -->|"opens details"| node_templatedetail
node_templatedetail -->|"loads template"| node_templateactions
node_templateactions -->|"detects variables"| node_parser
node_user -.->|"forks template"| node_templateactions
node_promptactions -->|"connects database"| node_database
node_templateactions -->|"connects database"| node_database
node_statsactions -->|"connects database"| node_database
node_database -->|"connects"| node_mongodb
node_promptactions -->|"reads and writes"| node_promptmodel
node_templateactions -->|"creates fork"| node_promptmodel
node_templateactions -->|"reads and writes"| node_templatemodel
node_statsactions -->|"counts prompts"| node_promptmodel
node_statsactions -->|"counts templates"| node_templatemodel

click node_dashboard "https://github.com/sanju1098/prompt-stack/blob/master/src/app/page.tsx"
click node_promptform "https://github.com/sanju1098/prompt-stack/blob/master/src/components/CreatePromptDialog.tsx"
click node_promptdetail "https://github.com/sanju1098/prompt-stack/blob/master/src/app/%5Bid%5D/prompt/page.tsx"
click node_templateform "https://github.com/sanju1098/prompt-stack/blob/master/src/components/CreateTemplateDialog.tsx"
click node_marketplace "https://github.com/sanju1098/prompt-stack/blob/master/src/app/templates/Template.tsx"
click node_templatedetail "https://github.com/sanju1098/prompt-stack/blob/master/src/app/%5Bid%5D/template/page.tsx"
click node_playground "https://github.com/sanju1098/prompt-stack/blob/master/src/app/%5Bid%5D/playground/Playground.tsx"
click node_promptactions "https://github.com/sanju1098/prompt-stack/blob/master/src/app/actions/promptActions.ts"
click node_templateactions "https://github.com/sanju1098/prompt-stack/blob/master/src/app/actions/templateActions.ts"
click node_statsactions "https://github.com/sanju1098/prompt-stack/blob/master/src/app/actions/statsActions.ts"
click node_parser "https://github.com/sanju1098/prompt-stack/blob/master/src/lib/parser.ts"
click node_promptmodel "https://github.com/sanju1098/prompt-stack/blob/master/src/models/Prompt.ts"
click node_templatemodel "https://github.com/sanju1098/prompt-stack/blob/master/src/models/Templates.ts"
click node_database "https://github.com/sanju1098/prompt-stack/blob/master/src/lib/database.ts"
click node_snippet "https://github.com/sanju1098/prompt-stack/blob/master/src/lib/codeSnippet.tsx"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dashboard,node_promptform,node_promptdetail,node_snippet,node_user toneBlue
class node_templateform,node_marketplace,node_templatedetail,node_mongodb toneAmber
class node_playground,node_parser,node_gemini,node_groq toneMint
class node_promptactions,node_templateactions,node_statsactions,node_promptmodel,node_templatemodel,node_database toneRose
```

## Components

### Prompt workspace

- [Prompt dashboard](https://github.com/sanju1098/prompt-stack/blob/master/src/app/page.tsx): `src/app/page.tsx`
- [Prompt editor](https://github.com/sanju1098/prompt-stack/blob/master/src/components/CreatePromptDialog.tsx): `src/components/CreatePromptDialog.tsx`
- [Prompt details](https://github.com/sanju1098/prompt-stack/blob/master/src/app/%5Bid%5D/prompt/page.tsx): `src/app/[id]/prompt/page.tsx`
- [Integration snippets](https://github.com/sanju1098/prompt-stack/blob/master/src/lib/codeSnippet.tsx): `src/lib/codeSnippet.tsx`

### Template marketplace

- [Template editor](https://github.com/sanju1098/prompt-stack/blob/master/src/components/CreateTemplateDialog.tsx): `src/components/CreateTemplateDialog.tsx`
- [Marketplace browser](https://github.com/sanju1098/prompt-stack/blob/master/src/app/templates/Template.tsx): `src/app/templates/Template.tsx`
- [Template details](https://github.com/sanju1098/prompt-stack/blob/master/src/app/%5Bid%5D/template/page.tsx): `src/app/[id]/template/page.tsx`

### Prompt runtime

- [Live playground](https://github.com/sanju1098/prompt-stack/blob/master/src/app/%5Bid%5D/playground/Playground.tsx): `src/app/[id]/playground/Playground.tsx`
- [Variable parser](https://github.com/sanju1098/prompt-stack/blob/master/src/lib/parser.ts): `src/lib/parser.ts`

### Persistence and services

- [Prompt actions](https://github.com/sanju1098/prompt-stack/blob/master/src/app/actions/promptActions.ts): `src/app/actions/promptActions.ts`
- [Template actions](https://github.com/sanju1098/prompt-stack/blob/master/src/app/actions/templateActions.ts): `src/app/actions/templateActions.ts`
- [Workspace statistics](https://github.com/sanju1098/prompt-stack/blob/master/src/app/actions/statsActions.ts): `src/app/actions/statsActions.ts`
- [Prompt schema](https://github.com/sanju1098/prompt-stack/blob/master/src/models/Prompt.ts): `src/models/Prompt.ts`
- [Template schema](https://github.com/sanju1098/prompt-stack/blob/master/src/models/Templates.ts): `src/models/Templates.ts`
- [MongoDB connection](https://github.com/sanju1098/prompt-stack/blob/master/src/lib/database.ts): `src/lib/database.ts`

### Other components

- **Workspace user**
- **MongoDB**
- **Gemini API**
- **Groq API**

## Connections

- Workspace user → Prompt dashboard: browses prompts
- Prompt dashboard → Prompt actions: searches prompts (evidence: `src/app/page.tsx`)
- Prompt dashboard → Workspace statistics: loads stats (evidence: `src/app/page.tsx`)
- Workspace user → Prompt editor: creates or edits (evidence: `src/components/CreatePromptDialog.tsx`)
- Prompt editor → Prompt actions: saves prompt (evidence: `src/components/CreatePromptDialog.tsx`)
- Prompt dashboard → Prompt details: opens details (evidence: `src/app/page.tsx`)
- Prompt details → Prompt actions: loads prompt (evidence: `src/app/[id]/prompt/page.tsx`)
- Prompt details → Integration snippets: shows examples (evidence: `src/app/[id]/prompt/page.tsx`)
- Prompt details → Live playground: opens testing (evidence: `src/app/[id]/prompt/page.tsx`)
- Workspace user → Live playground: tests prompt
- Live playground → Prompt actions: executes prompt (evidence: `src/app/[id]/playground/page.tsx`)
- Prompt actions → Variable parser: hydrates variables (evidence: `src/app/actions/promptActions.ts`)
- Prompt actions → Gemini API: generates content (evidence: `src/app/actions/promptActions.ts`)
- Prompt actions → Groq API: generates completion (evidence: `src/app/actions/promptActions.ts`)
- Workspace user → Marketplace browser: browses templates
- Marketplace browser → Template actions: loads templates (evidence: `src/app/templates/Template.tsx`)
- Workspace user → Template editor: publishes template (evidence: `src/components/CreateTemplateDialog.tsx`)
- Template editor → Template actions: creates template (evidence: `src/components/CreateTemplateDialog.tsx`)
- Marketplace browser → Template details: opens details
- Template details → Template actions: loads template (evidence: `src/app/[id]/template/page.tsx`)
- Template actions → Variable parser: detects variables (evidence: `src/app/actions/templateActions.ts`)
- Workspace user → Template actions: forks template
- Prompt actions → MongoDB connection: connects database (evidence: `src/app/actions/promptActions.ts`)
- Template actions → MongoDB connection: connects database (evidence: `src/app/actions/templateActions.ts`)
- Workspace statistics → MongoDB connection: connects database (evidence: `src/app/actions/statsActions.ts`)
- MongoDB connection → MongoDB: connects (evidence: `src/lib/database.ts`)
- Prompt actions → Prompt schema: reads and writes (evidence: `src/app/actions/promptActions.ts`)
- Template actions → Prompt schema: creates fork (evidence: `src/app/actions/templateActions.ts`)
- Template actions → Template schema: reads and writes (evidence: `src/app/actions/templateActions.ts`)
- Workspace statistics → Prompt schema: counts prompts (evidence: `src/app/actions/statsActions.ts`)
- Workspace statistics → Template schema: counts templates (evidence: `src/app/actions/statsActions.ts`)
