# hsbhasib/prompthive-a10 architecture

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

- Interactive diagram: https://gitdiagram.com/hsbhasib/prompthive-a10
- Repository: https://github.com/hsbhasib/prompthive-a10

## Overview

1. **Overall shape**
   - PromptHive is a **Next.js App Router** application organized around three major experiences: a public marketing/discovery site, authenticated role-based dashboards, and prompt detail/payment flows.
   - The codebase is primarily a **frontend application** that delegates data access and mutations to a `src/lib` integration layer.

2. **Routing and page composition**
   - `src/app` defines the route structure with route groups for **auth**, **dashboard**, **payments**, **prompt details**, and public pages.
   - Most route files are thin wrappers that mount feature components from `src/components`, which keeps routing separate from domain UI.

3. **Public-facing discovery layer**
   - The landing page and discovery surfaces are built from `homePage` components such as banner, featured prompts, top creators, reviews, FAQ, and footer.
   - The `all-prompts` and `prompt/[id]` routes support browsing, filtering, and prompt detail viewing for unauthenticated or authenticated users.

4. **Authentication and session boundary**
   - Authentication is handled through **BetterAuth** with a dedicated API route at `src/app/api/auth/[...all]/route.js`.
   - `src/lib/auth-client.js`, `src/lib/auth.js`, and `src/lib/core/session.js` likely centralize client/server session access and route protection.
   - Separate `/auth/login`, `/auth/register`, `/unauthorized`, and `/forbidden` pages indicate explicit auth and authorization boundaries.

5. **Role-based dashboard architecture**
   - The dashboard is split into **user**, **creator**, and **admin** subtrees under `src/app/dashboard`.
   - Each role has its own layout and feature pages, which is a strong sign that navigation and access control are enforced at the layout level rather than inside individual widgets.

6. **Prompt management domain**
   - Prompt creation and editing flows are centered around `promptForm`, `promptContent`, and role-specific add-prompt pages.
   - The domain supports create/update/delete, public vs premium visibility, prompt analytics, and moderation states such as reported or rejected prompts.

7. **Community interactions**
   - Prompt detail pages combine content, reviews, reporting, and bookmark actions.
   - Supporting modules under `promptDetails`, `user/my-reviews`, `user/saved-prompts`, and `dashboard/promptContent` show that prompt engagement is a first-class subsystem, not just a read-only catalog.

8. **Payments and subscription flow**
   - Stripe is integrated through `src/app/api/checkout_sessions/route.js`, with a dedicated `/payments` experience and `/payments/success` completion page.
   - The payment subsystem is tied to premium access, subscription status, and payment history shown in dashboards and admin views.

9. **Analytics and operational dashboards**
   - Creator analytics focus on prompt performance: total prompts, copies, bookmarks, and growth charts using **Recharts**.
   - Admin analytics add platform-level metrics like users, prompts, reviews, revenue, and moderation queues.
   - These dashboard views are separated into specialized content components, suggesting a presentation layer over aggregated backend data.

10. **Admin moderation and governance**
   - Admin pages for all users, all payments, all prompts, and reported prompts indicate a moderation/operations boundary distinct from normal creator and user workflows.
   - Components like delete dialogs, rejection modals, and reported prompt content imply admin actions are intentionally gated and confirmation-driven.

11. **Integration layer**
   - `src/lib/api` contains request modules for prompts, users, reviews, bookmarks, reports, subscriptions, plans, and top creators.
   - `src/lib/action` appears to hold mutation-oriented helpers for the same domains, likely used by client/server components to keep business logic out of pages.
   - This layer is the main abstraction between UI and external services or backend endpoints.

12. **External services and infrastructure**
   - The app depends on **Stripe** for payments, **ImgBB** for image uploads, and likely a MongoDB-backed API on the backend side per the README.
   - UI/UX relies on **HeroUI**, **Tailwind CSS**, **Framer Motion**, **React Hot Toast**, and **Axios**, while charts are rendered with **Recharts**.

13. **Shared UI and cross-cutting components**
   - Common shell pieces such as the navbar, sidebar, logo, loading/error states, and reusable dialogs are factored into shared components.
   - This keeps repeated structure out of page files and makes the dashboard, prompt detail, and marketing pages consistent.

14. **Important architectural boundary to capture in a diagram**
   - The cleanest diagram is: **route/layout layer → feature components → lib/api/lib/action integration layer → external services/backend**.
   - Role-based layouts and auth middleware-like behavior form the main security boundary, while payments, prompt moderation, and analytics are the main domain boundaries.

Main entry points: [`src/lib/api/prompts.js`](https://github.com/hsbhasib/prompthive-a10/blob/main/src/lib/api/prompts.js) (API modules), [`src/app/dashboard/layout.jsx`](https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/dashboard/layout.jsx) (Dashboard shell), [`src/app/layout.js`](https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/layout.js) (Root app), [`src/components/promptDetails/PromptDetails.jsx`](https://github.com/hsbhasib/prompthive-a10/blob/main/src/components/promptDetails/PromptDetails.jsx) (Prompt details UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App routes"]
  node_app_root["Root app<br/>layout/page shell<br/>[layout.js]"]
  node_app_home["Home page<br/>public route<br/>[page.js]"]
  node_app_all_prompts["All prompts<br/>listing route<br/>[page.jsx]"]
  node_app_prompt_detail["Prompt detail<br/>detail route<br/>[page.jsx]"]
  node_app_auth["Auth routes<br/>[page.jsx]"]
  node_app_dashboard["Dashboard shell<br/>protected layout<br/>[layout.jsx]"]
  node_app_user_dashboard["User area<br/>role routes<br/>[layout.jsx]"]
  node_app_creator_dashboard["Creator area<br/>role routes<br/>[layout.jsx]"]
  node_app_admin_dashboard["Admin area<br/>role routes<br/>[layout.jsx]"]
  node_app_payments["Payments<br/>billing route<br/>[page.jsx]"]
  node_app_auth_api["Auth API<br/>api route<br/>[route.js]"]
  node_app_checkout_api["Checkout API<br/>api route<br/>[route.js]"]
end

subgraph group_ui["Feature UI"]
  node_ui_home["Home sections<br/>marketing UI"]
  node_ui_prompts["Prompt browse UI<br/>catalog UI"]
  node_ui_prompt_details["Prompt details UI<br/>engagement UI<br/>[PromptDetails.jsx]"]
  node_ui_dashboard_prompt["Prompt editor<br/>prompt UI<br/>[PromptForm.jsx]"]
  node_ui_user_dashboard["User dashboard UI<br/>user UI"]
  node_ui_creator_dashboard["Creator analytics<br/>creator UI<br/>[ChartsData.jsx]"]
  node_ui_admin_dashboard["Admin ops UI<br/>admin UI"]
  node_ui_payments["Checkout UI<br/>billing UI<br/>[CheckoutForm.jsx]"]
end

subgraph group_lib["Integration layer"]
  node_lib_api["API modules<br/>read services<br/>[prompts.js]"]
  node_lib_action["Action modules<br/>mutations<br/>[prompts.js]"]
  node_lib_auth["Auth/session<br/>security layer<br/>[auth.js]"]
  node_lib_core["Core adapters<br/>service adapters<br/>[server.js]"]
end

subgraph group_infra["External services"]
  node_infra_backend[("Backend API<br/>application backend")]
  node_infra_betterauth(("BetterAuth<br/>auth provider"))
  node_infra_stripe(("Stripe<br/>payments provider"))
  node_infra_imgbb(("ImgBB<br/>image upload"))
end

node_app_root -->|"renders"| node_app_home
node_app_root -->|"hosts"| node_app_dashboard
node_app_root -->|"hosts"| node_app_auth
node_app_home -->|"mounts"| node_ui_home
node_app_all_prompts -->|"mounts"| node_ui_prompts
node_app_prompt_detail -->|"mounts"| node_ui_prompt_details
node_app_payments -->|"mounts"| node_ui_payments
node_app_dashboard -->|"subtree"| node_app_user_dashboard
node_app_dashboard -->|"subtree"| node_app_creator_dashboard
node_app_dashboard -->|"subtree"| node_app_admin_dashboard
node_app_user_dashboard -->|"mounts"| node_ui_user_dashboard
node_app_creator_dashboard -->|"mounts"| node_ui_creator_dashboard
node_app_admin_dashboard -->|"mounts"| node_ui_admin_dashboard
node_ui_prompts -->|"reads"| node_lib_api
node_ui_prompt_details -->|"reads"| node_lib_api
node_ui_prompt_details -->|"writes"| node_lib_action
node_ui_dashboard_prompt -->|"writes"| node_lib_action
node_ui_user_dashboard -->|"reads"| node_lib_api
node_ui_creator_dashboard -->|"reads"| node_lib_api
node_ui_admin_dashboard -->|"reads"| node_lib_api
node_ui_payments -->|"reads"| node_lib_api
node_ui_payments -->|"submits"| node_app_checkout_api
node_app_auth_api -->|"uses"| node_lib_auth
node_lib_auth -->|"connects"| node_infra_betterauth
node_lib_api -->|"calls"| node_infra_backend
node_lib_action -->|"mutates"| node_infra_backend
node_lib_core -->|"adapts"| node_infra_stripe
node_lib_core -->|"adapts"| node_infra_imgbb
node_app_checkout_api -->|"creates session"| node_infra_stripe

click node_app_root "https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/layout.js"
click node_app_home "https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/page.js"
click node_app_all_prompts "https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/all-prompts/page.jsx"
click node_app_prompt_detail "https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/prompt/[id]/page.jsx"
click node_app_auth "https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/auth/login/page.jsx"
click node_app_dashboard "https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/dashboard/layout.jsx"
click node_app_user_dashboard "https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/dashboard/user/layout.jsx"
click node_app_creator_dashboard "https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/dashboard/creator/layout.jsx"
click node_app_admin_dashboard "https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/dashboard/admin/layout.jsx"
click node_app_payments "https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/payments/page.jsx"
click node_app_auth_api "https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/api/auth/[...all]/route.js"
click node_app_checkout_api "https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/api/checkout_sessions/route.js"
click node_ui_home "https://github.com/hsbhasib/prompthive-a10/tree/main/src/components/homePage"
click node_ui_prompts "https://github.com/hsbhasib/prompthive-a10/blob/main/src/components/allPrompts/AllPromptsContent.jsx"
click node_ui_prompt_details "https://github.com/hsbhasib/prompthive-a10/blob/main/src/components/promptDetails/PromptDetails.jsx"
click node_ui_dashboard_prompt "https://github.com/hsbhasib/prompthive-a10/blob/main/src/components/dashboard/promptForm/PromptForm.jsx"
click node_ui_user_dashboard "https://github.com/hsbhasib/prompthive-a10/blob/main/src/components/dashboard/user/myReviewsContent/MyReviewsContent.jsx"
click node_ui_creator_dashboard "https://github.com/hsbhasib/prompthive-a10/blob/main/src/components/dashboard/creator/creatorHome/ChartsData.jsx"
click node_ui_admin_dashboard "https://github.com/hsbhasib/prompthive-a10/blob/main/src/components/dashboard/admin/analytics/AdminAnalyticsContent.jsx"
click node_ui_payments "https://github.com/hsbhasib/prompthive-a10/blob/main/src/components/paymentsContent/CheckoutForm.jsx"
click node_lib_api "https://github.com/hsbhasib/prompthive-a10/blob/main/src/lib/api/prompts.js"
click node_lib_action "https://github.com/hsbhasib/prompthive-a10/blob/main/src/lib/action/prompts.js"
click node_lib_auth "https://github.com/hsbhasib/prompthive-a10/blob/main/src/lib/auth.js"
click node_lib_core "https://github.com/hsbhasib/prompthive-a10/blob/main/src/lib/core/server.js"

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_root,node_app_home,node_app_all_prompts,node_app_prompt_detail,node_app_auth,node_app_dashboard,node_app_user_dashboard,node_app_creator_dashboard,node_app_admin_dashboard,node_app_payments,node_app_auth_api,node_app_checkout_api toneBlue
class node_ui_home,node_ui_prompts,node_ui_prompt_details,node_ui_dashboard_prompt,node_ui_user_dashboard,node_ui_creator_dashboard,node_ui_admin_dashboard,node_ui_payments toneAmber
class node_lib_api,node_lib_action,node_lib_auth,node_lib_core toneMint
class node_infra_backend,node_infra_betterauth,node_infra_stripe,node_infra_imgbb toneRose
```

## Components

### App routes

Next.js App Router pages, layouts, and API routes.

- [Root app](https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/layout.js): layout/page shell · Global app shell, metadata, and top-level error/loading states. · `src/app/layout.js`
- [Home page](https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/page.js): public route · Landing page for discovery and marketing. · `src/app/page.js`
- [All prompts](https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/all-prompts/page.jsx): listing route · Prompt browsing and filtering experience. · `src/app/all-prompts/page.jsx`
- [Prompt detail](https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/prompt/[id]/page.jsx): detail route · Single prompt view with engagement and reporting. · `src/app/prompt/[id]/page.jsx`
- [Auth routes](https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/auth/login/page.jsx): auth routes · Login and register pages under the auth boundary. · `src/app/auth/login/page.jsx`
- [Dashboard shell](https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/dashboard/layout.jsx): protected layout · Shared dashboard layout for role-based sections. · `src/app/dashboard/layout.jsx`
- [User area](https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/dashboard/user/layout.jsx): role routes · User-facing dashboard subtree. · `src/app/dashboard/user/layout.jsx`
- [Creator area](https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/dashboard/creator/layout.jsx): role routes · Creator-facing dashboard subtree. · `src/app/dashboard/creator/layout.jsx`
- [Admin area](https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/dashboard/admin/layout.jsx): role routes · Admin-facing dashboard subtree. · `src/app/dashboard/admin/layout.jsx`
- [Payments](https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/payments/page.jsx): billing route · Checkout and post-payment experience. · `src/app/payments/page.jsx`
- [Auth API](https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/api/auth/[...all]/route.js): api route · BetterAuth endpoint for authentication flows. · `src/app/api/auth/[...all]/route.js`
- [Checkout API](https://github.com/hsbhasib/prompthive-a10/blob/main/src/app/api/checkout_sessions/route.js): api route · Stripe checkout session endpoint. · `src/app/api/checkout_sessions/route.js`

### Feature UI

Route-mounted feature components and shared presentation modules.

- [Home sections](https://github.com/hsbhasib/prompthive-a10/tree/main/src/components/homePage): marketing UI · Banner, featured prompts, creators, reviews, FAQ, and footer. · `src/components/homePage`
- [Prompt browse UI](https://github.com/hsbhasib/prompthive-a10/blob/main/src/components/allPrompts/AllPromptsContent.jsx): catalog UI · Prompt listing and discovery content. · `src/components/allPrompts/AllPromptsContent.jsx`
- [Prompt details UI](https://github.com/hsbhasib/prompthive-a10/blob/main/src/components/promptDetails/PromptDetails.jsx): engagement UI · Prompt content, reviews, and reporting actions. · `src/components/promptDetails/PromptDetails.jsx`
- [Prompt editor](https://github.com/hsbhasib/prompthive-a10/blob/main/src/components/dashboard/promptForm/PromptForm.jsx): prompt UI · Create, update, and delete prompt forms for dashboard flows. · `src/components/dashboard/promptForm/PromptForm.jsx`
- [User dashboard UI](https://github.com/hsbhasib/prompthive-a10/blob/main/src/components/dashboard/user/myReviewsContent/MyReviewsContent.jsx): user UI · Saved prompts, reviews, and user add-prompt content. · `src/components/dashboard/user/myReviewsContent/MyReviewsContent.jsx`
- [Creator analytics](https://github.com/hsbhasib/prompthive-a10/blob/main/src/components/dashboard/creator/creatorHome/ChartsData.jsx): creator UI · Creator home metrics and charts. · `src/components/dashboard/creator/creatorHome/ChartsData.jsx`
- [Admin ops UI](https://github.com/hsbhasib/prompthive-a10/blob/main/src/components/dashboard/admin/analytics/AdminAnalyticsContent.jsx): admin UI · User, payment, prompt, and moderation management views. · `src/components/dashboard/admin/analytics/AdminAnalyticsContent.jsx`
- [Checkout UI](https://github.com/hsbhasib/prompthive-a10/blob/main/src/components/paymentsContent/CheckoutForm.jsx): billing UI · Payment form and subscription information. · `src/components/paymentsContent/CheckoutForm.jsx`

### Integration layer

Client/server APIs, mutations, auth, session, and service adapters.

- [API modules](https://github.com/hsbhasib/prompthive-a10/blob/main/src/lib/api/prompts.js): read services · Prompt, user, review, bookmark, report, subscription, plan, and creator fetchers. · `src/lib/api/prompts.js`
- [Action modules](https://github.com/hsbhasib/prompthive-a10/blob/main/src/lib/action/prompts.js): mutations · Create/update/delete and workflow actions for prompts, users, reviews, bookmarks, and reports. · `src/lib/action/prompts.js`
- [Auth/session](https://github.com/hsbhasib/prompthive-a10/blob/main/src/lib/auth.js): security layer · Client auth, server auth, and session helpers. · `src/lib/auth.js`
- [Core adapters](https://github.com/hsbhasib/prompthive-a10/blob/main/src/lib/core/server.js): service adapters · Shared backend adapters for server, session, ImageBB, and Stripe. · `src/lib/core/server.js`

### External services

Third-party services and backend dependencies.

- **Backend API**: application backend · Primary data backend used by the app's integration layer.
- **BetterAuth**: auth provider · Authentication provider behind the auth API.
- **Stripe**: payments provider · Checkout and subscription billing provider.
- **ImgBB**: image upload · External image hosting used for uploads.

## Connections

- Root app → Home page: renders · Root app composes the public landing experience.
- Root app → Dashboard shell: hosts · Top-level shell contains protected dashboard routes.
- Root app → Auth routes: hosts · Top-level shell contains auth pages.
- Home page → Home sections: mounts · Home page is assembled from marketing sections.
- All prompts → Prompt browse UI: mounts · Listing route delegates to prompt browse UI.
- Prompt detail → Prompt details UI: mounts · Detail route delegates to prompt engagement UI.
- Payments → Checkout UI: mounts · Payments route delegates to checkout UI.
- Dashboard shell → User area: subtree · Dashboard shell branches into user area.
- Dashboard shell → Creator area: subtree · Dashboard shell branches into creator area.
- Dashboard shell → Admin area: subtree · Dashboard shell branches into admin area.
- User area → User dashboard UI: mounts · User routes mount user-specific dashboard content.
- Creator area → Creator analytics: mounts · Creator routes mount analytics and management UI.
- Admin area → Admin ops UI: mounts · Admin routes mount operational and moderation UI.
- Prompt browse UI → API modules: reads · Discovery UI fetches prompt and related catalog data.
- Prompt details UI → API modules: reads · Prompt details load content, reviews, bookmarks, and reports.
- Prompt details UI → Action modules: writes · Prompt engagement triggers mutations such as reviews and reports.
- Prompt editor → Action modules: writes · Prompt editor uses mutation helpers for create/update/delete.
- User dashboard UI → API modules: reads · User dashboard loads saved prompts, reviews, and profile data.
- Creator analytics → API modules: reads · Creator analytics read prompt performance and growth data.
- Admin ops UI → API modules: reads · Admin views aggregate users, payments, prompts, and reports.
- Checkout UI → API modules: reads · Checkout UI loads plan and payment context.
- Checkout UI → Checkout API: submits · Checkout form creates Stripe sessions through the API route.
- Auth API → Auth/session: uses · Auth API is wired to the shared auth/session layer.
- Auth/session → BetterAuth: connects · Auth helpers wrap the external authentication provider.
- API modules → Backend API: calls · Read modules talk to the backend service layer.
- Action modules → Backend API: mutates · Action modules perform backend writes and workflow changes.
- Core adapters → Stripe: adapts · Core Stripe adapter supports billing flows.
- Core adapters → ImgBB: adapts · Core image adapter supports prompt media uploads.
- Checkout API → Stripe: creates session · Checkout endpoint creates Stripe checkout sessions.
