# naseem2917/promptwise architecture

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

- Interactive diagram: https://gitdiagram.com/naseem2917/promptwise
- Repository: https://github.com/naseem2917/promptwise

## Overview

PromptWise is a student-facing AI literacy workbench. Students can learn prompt principles, browse examples, take a quiz, or improve a prompt through validation, clarification questions, AI analysis and synthesis, then review scores and export the result to an external chatbot. Signed-in users can sync prompts and practice data; session drafts preserve in-progress work. The excerpts show the improvement/API and Firebase paths directly, while several other capabilities are documented in the README but their detailed implementations were not sampled.

Main entry points: [`src/App.tsx`](https://github.com/naseem2917/promptwise/blob/main/src/App.tsx) (Route Shell), [`src/pages/Improve.tsx`](https://github.com/naseem2917/promptwise/blob/main/src/pages/Improve.tsx) (Improve Workflow), [`src/lib/db.ts`](https://github.com/naseem2917/promptwise/blob/main/src/lib/db.ts) (Firestore Access), [`src/pages/Quiz.tsx`](https://github.com/naseem2917/promptwise/blob/main/src/pages/Quiz.tsx) (Practice Quiz)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Student Experience"]
  node_app["Route Shell<br/>[App.tsx]"]
  node_home["Home<br/>[Home.tsx]"]
  node_feedback["Student Feedback<br/>[Feedback.tsx]"]
end

subgraph group_improvement["Prompt Improvement"]
  node_improve["Improve Workflow<br/>[Improve.tsx]"]
  node_promptinput["Prompt Input<br/>[PromptInput.tsx]"]
  node_questioncard["Follow-up Questions<br/>[QuestionCard.tsx]"]
  node_score["Diagnostic Score<br/>[ScoreDisplay.tsx]"]
  node_beforeafter["Prompt Comparison<br/>[BeforeAfter.tsx]"]
  node_explanation["Change Rationale"]
  node_chatbot["Chatbot Export<br/>[ChatbotToolbar.tsx]"]
end

subgraph group_learning["Learning and Practice"]
  node_learn["Learning Guides<br/>[Learn.tsx]"]
  node_examples["Prompt Examples<br/>[Examples.tsx]"]
  node_quiz["Practice Quiz<br/>[Quiz.tsx]"]
end

subgraph group_accounts["Accounts and Persistence"]
  node_dashboard["Student Dashboard<br/>[Dashboard.tsx]"]
  node_history["Prompt History<br/>[History.tsx]"]
  node_admin["Feedback Admin<br/>[Admin.tsx]"]
  node_auth["Auth State<br/>[AuthContext.tsx]"]
  node_authlib["Google Sign-in<br/>[auth.ts]"]
  node_firebase["Firebase Client<br/>[firebase.ts]"]
  node_db[("Firestore Access<br/>[db.ts]")]
  node_session["Session History<br/>[sessionHistory.ts]"]
end

subgraph group_service["AI Service"]
  node_api["AI API Client<br/>[api.ts]"]
  node_worker["Cloudflare Worker<br/>[index.ts]"]
end

node_student(("Student"))
node_ai{{"AI Models"}}
node_externalchat{{"External Chatbots"}}

node_student -->|"uses"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_improve
node_app -->|"routes to"| node_learn
node_app -->|"routes to"| node_examples
node_app -->|"routes to"| node_quiz
node_app -->|"routes to"| node_feedback
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_history
node_app -->|"routes to"| node_admin
node_improve -->|"renders"| node_promptinput
node_improve -->|"renders"| node_questioncard
node_improve -->|"renders"| node_score
node_improve -->|"renders"| node_beforeafter
node_improve -->|"renders"| node_explanation
node_improve -->|"requests analysis and synthesis"| node_api
node_improve -->|"saves prompt"| node_db
node_improve -->|"preserves drafts"| node_session
node_beforeafter -->|"offers export"| node_chatbot
node_chatbot -->|"opens chatbot"| node_externalchat
node_api -.->|"sends API requests"| node_worker
node_worker -->|"uses model failover"| node_ai
node_quiz -->|"requests quiz"| node_api
node_quiz -->|"saves quiz result"| node_db
node_feedback -->|"submits feedback"| node_db
node_admin -->|"loads feedback"| node_db
node_dashboard -->|"loads practice data"| node_db
node_history -->|"loads prompt records"| node_db
node_auth -->|"observes auth"| node_firebase
node_auth -->|"upserts user"| node_db
node_authlib -->|"signs in"| node_firebase
node_db -->|"reads and writes"| node_firebase
node_session -->|"maps prompt records"| node_db
node_student -->|"studies prompt craft"| node_learn
node_student -->|"explores templates"| node_examples
node_student -->|"practices skills"| node_quiz
node_student -->|"submits feedback"| node_feedback

click node_app "https://github.com/naseem2917/promptwise/blob/main/src/App.tsx"
click node_home "https://github.com/naseem2917/promptwise/blob/main/src/pages/Home.tsx"
click node_feedback "https://github.com/naseem2917/promptwise/blob/main/src/pages/Feedback.tsx"
click node_improve "https://github.com/naseem2917/promptwise/blob/main/src/pages/Improve.tsx"
click node_promptinput "https://github.com/naseem2917/promptwise/blob/main/src/components/improve/PromptInput.tsx"
click node_questioncard "https://github.com/naseem2917/promptwise/blob/main/src/components/improve/QuestionCard.tsx"
click node_score "https://github.com/naseem2917/promptwise/blob/main/src/components/improve/ScoreDisplay.tsx"
click node_beforeafter "https://github.com/naseem2917/promptwise/blob/main/src/components/improve/BeforeAfter.tsx"
click node_explanation "https://github.com/naseem2917/promptwise/blob/main/src/components/improve/ExplanationPanel.tsx"
click node_chatbot "https://github.com/naseem2917/promptwise/blob/main/src/components/ui/ChatbotToolbar.tsx"
click node_learn "https://github.com/naseem2917/promptwise/blob/main/src/pages/Learn.tsx"
click node_examples "https://github.com/naseem2917/promptwise/blob/main/src/pages/Examples.tsx"
click node_quiz "https://github.com/naseem2917/promptwise/blob/main/src/pages/Quiz.tsx"
click node_dashboard "https://github.com/naseem2917/promptwise/blob/main/src/pages/Dashboard.tsx"
click node_history "https://github.com/naseem2917/promptwise/blob/main/src/pages/History.tsx"
click node_admin "https://github.com/naseem2917/promptwise/blob/main/src/pages/Admin.tsx"
click node_auth "https://github.com/naseem2917/promptwise/blob/main/src/contexts/AuthContext.tsx"
click node_authlib "https://github.com/naseem2917/promptwise/blob/main/src/lib/auth.ts"
click node_firebase "https://github.com/naseem2917/promptwise/blob/main/src/lib/firebase.ts"
click node_db "https://github.com/naseem2917/promptwise/blob/main/src/lib/db.ts"
click node_session "https://github.com/naseem2917/promptwise/blob/main/src/lib/sessionHistory.ts"
click node_api "https://github.com/naseem2917/promptwise/blob/main/src/lib/api.ts"
click node_worker "https://github.com/naseem2917/promptwise/blob/main/worker/index.ts"

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_app,node_home,node_feedback toneBlue
class node_improve,node_promptinput,node_questioncard,node_score,node_beforeafter,node_explanation,node_chatbot toneAmber
class node_learn,node_examples,node_quiz toneMint
class node_dashboard,node_history,node_admin,node_auth,node_authlib,node_firebase,node_db,node_session toneRose
class node_api,node_worker,node_student,node_ai,node_externalchat toneIndigo
```

## Components

### Student Experience

- [Route Shell](https://github.com/naseem2917/promptwise/blob/main/src/App.tsx): `src/App.tsx`
- [Home](https://github.com/naseem2917/promptwise/blob/main/src/pages/Home.tsx): `src/pages/Home.tsx`
- [Student Feedback](https://github.com/naseem2917/promptwise/blob/main/src/pages/Feedback.tsx): `src/pages/Feedback.tsx`

### Prompt Improvement

- [Improve Workflow](https://github.com/naseem2917/promptwise/blob/main/src/pages/Improve.tsx): `src/pages/Improve.tsx`
- [Prompt Input](https://github.com/naseem2917/promptwise/blob/main/src/components/improve/PromptInput.tsx): `src/components/improve/PromptInput.tsx`
- [Follow-up Questions](https://github.com/naseem2917/promptwise/blob/main/src/components/improve/QuestionCard.tsx): `src/components/improve/QuestionCard.tsx`
- [Diagnostic Score](https://github.com/naseem2917/promptwise/blob/main/src/components/improve/ScoreDisplay.tsx): `src/components/improve/ScoreDisplay.tsx`
- [Prompt Comparison](https://github.com/naseem2917/promptwise/blob/main/src/components/improve/BeforeAfter.tsx): `src/components/improve/BeforeAfter.tsx`
- [Change Rationale](https://github.com/naseem2917/promptwise/blob/main/src/components/improve/ExplanationPanel.tsx): `src/components/improve/ExplanationPanel.tsx`
- [Chatbot Export](https://github.com/naseem2917/promptwise/blob/main/src/components/ui/ChatbotToolbar.tsx): `src/components/ui/ChatbotToolbar.tsx`

### Learning and Practice

- [Learning Guides](https://github.com/naseem2917/promptwise/blob/main/src/pages/Learn.tsx): `src/pages/Learn.tsx`
- [Prompt Examples](https://github.com/naseem2917/promptwise/blob/main/src/pages/Examples.tsx): `src/pages/Examples.tsx`
- [Practice Quiz](https://github.com/naseem2917/promptwise/blob/main/src/pages/Quiz.tsx): `src/pages/Quiz.tsx`

### Accounts and Persistence

- [Student Dashboard](https://github.com/naseem2917/promptwise/blob/main/src/pages/Dashboard.tsx): `src/pages/Dashboard.tsx`
- [Prompt History](https://github.com/naseem2917/promptwise/blob/main/src/pages/History.tsx): `src/pages/History.tsx`
- [Feedback Admin](https://github.com/naseem2917/promptwise/blob/main/src/pages/Admin.tsx): `src/pages/Admin.tsx`
- [Auth State](https://github.com/naseem2917/promptwise/blob/main/src/contexts/AuthContext.tsx): `src/contexts/AuthContext.tsx`
- [Google Sign-in](https://github.com/naseem2917/promptwise/blob/main/src/lib/auth.ts): `src/lib/auth.ts`
- [Firebase Client](https://github.com/naseem2917/promptwise/blob/main/src/lib/firebase.ts): `src/lib/firebase.ts`
- [Firestore Access](https://github.com/naseem2917/promptwise/blob/main/src/lib/db.ts): `src/lib/db.ts`
- [Session History](https://github.com/naseem2917/promptwise/blob/main/src/lib/sessionHistory.ts): `src/lib/sessionHistory.ts`

### AI Service

- [AI API Client](https://github.com/naseem2917/promptwise/blob/main/src/lib/api.ts): `src/lib/api.ts`
- [Cloudflare Worker](https://github.com/naseem2917/promptwise/blob/main/worker/index.ts): `worker/index.ts`

### Other components

- **Student**
- **AI Models**
- **External Chatbots**

## Connections

- Student → Route Shell: uses (evidence: `README.md`)
- Route Shell → Home: routes to (evidence: `src/App.tsx`)
- Route Shell → Improve Workflow: routes to (evidence: `src/App.tsx`)
- Route Shell → Learning Guides: routes to (evidence: `src/App.tsx`)
- Route Shell → Prompt Examples: routes to (evidence: `src/App.tsx`)
- Route Shell → Practice Quiz: routes to (evidence: `src/App.tsx`)
- Route Shell → Student Feedback: routes to (evidence: `src/App.tsx`)
- Route Shell → Student Dashboard: routes to (evidence: `src/App.tsx`)
- Route Shell → Prompt History: routes to (evidence: `src/App.tsx`)
- Route Shell → Feedback Admin: routes to (evidence: `src/App.tsx`)
- Improve Workflow → Prompt Input: renders (evidence: `src/pages/Improve.tsx`)
- Improve Workflow → Follow-up Questions: renders (evidence: `src/pages/Improve.tsx`)
- Improve Workflow → Diagnostic Score: renders (evidence: `src/pages/Improve.tsx`)
- Improve Workflow → Prompt Comparison: renders (evidence: `src/pages/Improve.tsx`)
- Improve Workflow → Change Rationale: renders (evidence: `src/pages/Improve.tsx`)
- Improve Workflow → AI API Client: requests analysis and synthesis (evidence: `src/pages/Improve.tsx`)
- Improve Workflow → Firestore Access: saves prompt (evidence: `src/pages/Improve.tsx`)
- Improve Workflow → Session History: preserves drafts (evidence: `src/pages/Improve.tsx`)
- Prompt Comparison → Chatbot Export: offers export (evidence: `src/components/improve/BeforeAfter.tsx`)
- Chatbot Export → External Chatbots: opens chatbot (evidence: `README.md`)
- AI API Client → Cloudflare Worker: sends API requests
- Cloudflare Worker → AI Models: uses model failover (evidence: `README.md`)
- Practice Quiz → AI API Client: requests quiz (evidence: `src/pages/Quiz.tsx`)
- Practice Quiz → Firestore Access: saves quiz result (evidence: `src/pages/Quiz.tsx`)
- Student Feedback → Firestore Access: submits feedback (evidence: `src/pages/Feedback.tsx`)
- Feedback Admin → Firestore Access: loads feedback (evidence: `src/pages/Admin.tsx`)
- Student Dashboard → Firestore Access: loads practice data (evidence: `src/pages/Dashboard.tsx`)
- Prompt History → Firestore Access: loads prompt records (evidence: `src/pages/History.tsx`)
- Auth State → Firebase Client: observes auth (evidence: `src/contexts/AuthContext.tsx`)
- Auth State → Firestore Access: upserts user (evidence: `src/contexts/AuthContext.tsx`)
- Google Sign-in → Firebase Client: signs in (evidence: `src/lib/auth.ts`)
- Firestore Access → Firebase Client: reads and writes (evidence: `src/lib/db.ts`)
- Session History → Firestore Access: maps prompt records (evidence: `src/lib/sessionHistory.ts`)
- Student → Learning Guides: studies prompt craft (evidence: `README.md`)
- Student → Prompt Examples: explores templates (evidence: `README.md`)
- Student → Practice Quiz: practices skills (evidence: `README.md`)
- Student → Student Feedback: submits feedback (evidence: `README.md`)
