How hsbhasib/prompthive-a10 works
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: prompts.js API modules · layout.jsx Dashboard shell · layout.js Root app · PromptDetails.jsx Prompt details UI
Components 28
App routes
Next.js App Router pages, layouts, and API routes.
- Root app · Global app shell, metadata, and top-level error/loading states.
src/app/layout.js - Home page · Landing page for discovery and marketing.
src/app/page.js - All prompts · Prompt browsing and filtering experience.
src/app/all-prompts/page.jsx - Prompt detail · Single prompt view with engagement and reporting.
src/app/prompt/[id]/page.jsx - Auth routes · Login and register pages under the auth boundary.
src/app/auth/login/page.jsx - Dashboard shell · Shared dashboard layout for role-based sections.
src/app/dashboard/layout.jsx - User area · User-facing dashboard subtree.
src/app/dashboard/user/layout.jsx - Creator area · Creator-facing dashboard subtree.
src/app/dashboard/creator/layout.jsx - Admin area · Admin-facing dashboard subtree.
src/app/dashboard/admin/layout.jsx - Payments · Checkout and post-payment experience.
src/app/payments/page.jsx - Auth API · BetterAuth endpoint for authentication flows.
src/app/api/auth/[...all]/route.js - Checkout API · Stripe checkout session endpoint.
src/app/api/checkout_sessions/route.js
Feature UI
Route-mounted feature components and shared presentation modules.
- Home sections · Banner, featured prompts, creators, reviews, FAQ, and footer.
src/components/homePage - Prompt browse UI · Prompt listing and discovery content.
src/components/allPrompts/AllPromptsContent.jsx - Prompt details UI · Prompt content, reviews, and reporting actions.
src/components/promptDetails/PromptDetails.jsx - Prompt editor · Create, update, and delete prompt forms for dashboard flows.
src/components/dashboard/promptForm/PromptForm.jsx - User dashboard UI · Saved prompts, reviews, and user add-prompt content.
src/components/dashboard/user/myReviewsContent/MyReviewsContent.jsx - Creator analytics · Creator home metrics and charts.
src/components/dashboard/creator/creatorHome/ChartsData.jsx - Admin ops UI · User, payment, prompt, and moderation management views.
src/components/dashboard/admin/analytics/AdminAnalyticsContent.jsx - Checkout UI · Payment form and subscription information.
src/components/paymentsContent/CheckoutForm.jsx
Integration layer
Client/server APIs, mutations, auth, session, and service adapters.
- API modules · Prompt, user, review, bookmark, report, subscription, plan, and creator fetchers.
src/lib/api/prompts.js - Action modules · Create/update/delete and workflow actions for prompts, users, reviews, bookmarks, and reports.
src/lib/action/prompts.js - Auth/session · Client auth, server auth, and session helpers.
src/lib/auth.js - Core 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 · Primary data backend used by the app's integration layer.
- BetterAuth · Authentication provider behind the auth API.
- Stripe · Checkout and subscription billing provider.
- ImgBB · External image hosting used for uploads.
Connections 29
- 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.