How dheerajok/digital-portfolio works
1. Top-level shape
- This is a Next.js App Router project with a mix of public marketing pages, authenticated dashboard pages, tenant-specific portfolio pages, and a sizeable API layer.
- The architecture is centered around a portfolio SaaS: users create/edit a portfolio in a dashboard, store it in MongoDB, and publish it under a username/custom link.
2. Public marketing and acquisition layer
- app/page.js plus pages like app/pricing, app/about, app/support, app/terms, app/privacy, and the blog/guide-style routes (how-to-create-portfolio-2025, how-to-make-video-editor-portfolio, online-portfolio-maker, portfolio-website-builder, etc.) form the public funnel.
- Reusable landing-page UI lives in app/components/home and shared UI primitives in components/ui.
3. Authenticated app shell and session boundary
- app/layout.js, app/contexts/SessionContext.js, app/contexts/UserContext.js, and app/components/SessionWrapper.js indicate a client/server session boundary around logged-in experiences.
- middleware.js likely protects routes or handles redirects/auth gating for dashboard and user-specific areas.
4. Dashboard subsystem
- app/dashboard is the product workspace: overview, analytics, edit portfolio, referrals, and settings.
- Sidebar, TopNavbar, and the section components suggest a single authenticated shell that swaps feature panels rather than separate standalone apps.
5. Portfolio builder/editor subsystem
- The core product logic is in app/dashboard/components/edit-portfolio.
- There are two main editing tracks: freelancer portfolios and video editor portfolios, each with its own editor component, step flow, and form fields.
- The multi-step forms in forms/* and steps/* imply a guided wizard that collects structured content, then persists it to the backend.
6. Template rendering subsystem
- Public portfolio pages are rendered from template sets under app/[username]/templates.
- There are distinct template families for different portfolio types and styles:
- freelancer-oriented templates
- video editor templates
- text/template descriptors for categories like marketing, designers, and linktree
- one named template set under dheerajok
- This suggests a content-model-to-template mapping where the stored portfolio data drives which frontend composition is shown.
7. Tenant/public portfolio routes
- app/[username]/page.js is the key dynamic route for a user’s public portfolio.
- app/[username]/websites/page.js appears to support a portfolio sub-section or listing page.
- NotPublic.jsx, Freelancer.jsx, VideoEditor.jsx, and analytics helper code in the same folder indicate the public route may branch based on visibility and portfolio type.
8. Backend API layer
- The app exposes many route handlers under app/api, organized by domain:
- portfolio CRUD and lookup
- video-editor-portfolio
- analytics tracking and batch tracking
- form submission
- image upload/delete
- auth via NextAuth
- AI generation/quota
- Razorpay payment/order verification
- referral registration, validation, dashboard, withdrawal
- admin cleanup/export
- This API layer is the central boundary between the dashboard/public UI and persistence/external services.
9. Data and persistence model
- MongoDB is the primary datastore, via app/db/mongodb.js.
- Mongoose-style models in app/model define the main entities:
- User
- Portfolio
- VideoEditorPortfolio
- AnalyticsSchema
- ImageModel
- The architecture is data-driven: portfolio content, analytics events, images, and user records are stored separately and served through API routes.
10. Analytics and behavioral tracking
- Analytics is first-class, with dedicated routes under app/api/analytics/[username] and app/api/track-batch.
- The dashboard has an Analytics section, and the public portfolios likely emit view/event data back to the backend for aggregation.
- app/model/AnalyticsSchema.js indicates event storage is part of the core domain, not an add-on.
11. AI-assisted content generation
- app/api/ai/generate-text and app/api/ai/quota support text generation inside the editor flow.
- app/dashboard/hooks/useAIGenerator.js and AI-specific form fields show AI is integrated directly into the portfolio creation experience, with quota enforcement as a backend concern.
12. Payments, billing, and monetization
- app/api/razorpay/create-order and app/api/razorpay/verify-payment show a payment flow backed by Razorpay.
- The presence of app/payment/page.js and app/api/admin/cleanup-unpaid suggests purchase state matters for access or provisioning.
- Pricing and payment are tightly coupled to dashboard actions rather than being a standalone checkout app.
13. Referral and growth loop
- app/api/referral/register, validate-code, dashboard, and withdraw indicate a referral system with account-level tracking and payout/withdrawal logic.
- The dashboard includes a dedicated Refer section, so referrals are a product feature integrated with user identity and monetization.
14. File/media handling
- upload-image and delete-image APIs, plus app/model/ImageModel.js, define a media storage workflow separate from portfolio documents.
- This implies portfolio entries reference uploaded assets rather than embedding raw files in the main portfolio records.
15. Build/runtime and deployment boundaries
- The repo uses standard Next.js/Vercel conventions: vercel.json, next.config.mjs, sitemap.js, robots.js, tailwind.config.mjs, and app-level CSS.
- Overall the system is a single Next.js deployment with server routes, client components, and MongoDB-backed state, rather than a multi-service architecture.
16. How data moves through the system
- A user signs in, creates or edits a portfolio in the dashboard, optionally uses AI/image upload/payment/referral features, and the client submits data through API routes.
- The backend stores structured records in MongoDB, then the public dynamic route under app/[username] reads that data and renders the appropriate template.
- Analytics and monetization flows run alongside this core loop, feeding back into dashboard views and admin endpoints.
Main entry points: dashboard/page.js Dashboard · mongodb.js MongoDB · app/page.js Home · [username]/page.js Tenant page
Components 28
Public funnel
Marketing pages, guides, and public portfolio rendering.
- Home · Top-level marketing entry page.
app/page.js - Hero UI · Reusable public landing-page sections.
app/components/home/HeroSection.jsx - Pricing · Pricing and monetization entry point.
app/pricing/page.js - Guides · SEO-oriented tutorial and acquisition pages.
app/how-to-create-portfolio-2025/page.js - Templates · Public template browsing and discovery.
app/templates/page.js
Dashboard app
Authenticated product workspace and editor shell.
- Dashboard · Authenticated product workspace entry.
app/dashboard/page.js - Panels · Overview, settings, analytics, and referral panels.
app/dashboard/components/Overview.jsx - Editor · Main entry for creating and updating portfolios.
app/dashboard/components/EditPortfolio.jsx - Freelancer edit · Guided freelancer portfolio editing flow.
app/dashboard/components/edit-portfolio/EditFreelancerPortfolio.jsx - Video edit · Guided video-editor portfolio editing flow.
app/dashboard/components/edit-portfolio/EditVideoEditorPortfolio.jsx
Portfolio runtime
Public tenant routes and template-driven profile pages.
- Tenant page · Public username-based portfolio route.
app/[username]/page.js - Freelancer view · Freelancer portfolio presentation branch.
app/[username]/Freelancer.jsx - Video view · Video editor portfolio presentation branch.
app/[username]/VideoEditor.jsx - Not public · Fallback for hidden or unavailable portfolios.
app/[username]/NotPublic.jsx - Templates pack · Template families and composition assets for public profiles.
API boundary
Route handlers for CRUD, AI, media, payments, referrals, and analytics.
- Auth · Authentication and session issuance boundary.
app/api/auth/[...nextauth]/route.js - Portfolio API · Primary portfolio persistence and lookup boundary.
app/api/portfolio/route.js - Video API · Video-editor portfolio persistence boundary.
app/api/video-editor-portfolio/route.js - Analytics API · Per-username analytics ingestion and aggregation.
app/api/analytics/[username]/route.js - Media API · Image upload and deletion workflow boundary.
app/api/upload-image/route.js - AI API · Text generation and quota enforcement endpoints.
app/api/ai/generate-text/route.js - Payments API · Razorpay order creation and payment verification.
app/api/razorpay/create-order/route.js - Referral API · Referral registration, validation, dashboard, and withdrawal endpoints.
app/api/referral/register/route.js
Data layer
MongoDB connection and domain models.
- MongoDB · Shared MongoDB connection helper.
app/db/mongodb.js - Models · Core persisted entities for users, portfolios, analytics, and images.
app/model/Portfolio.js - Analytics model · Stored analytics event schema.
app/model/AnalyticsSchema.js
Connections 31
- Home → Hero UI: uses · Landing page composes shared marketing sections.
- Home → Pricing: links · Public homepage routes users to pricing.
- Home → Guides: acquires · SEO guides feed the acquisition funnel.
- Home → Templates: shows · Template browsing is part of the public funnel.
- Session → Dashboard: wraps · Session wrapper guards the authenticated workspace.
- Auth → Session: issues · Auth route supplies the session boundary.
- Dashboard → Panels: switches · Dashboard swaps between feature panels.
- Dashboard → Editor: opens · Workspace launches the portfolio editor.
- Editor → Freelancer edit: loads · Freelancer portfolio editing flow.
- Editor → Video edit: loads · Video editor portfolio editing flow.
- Editor → AI hook: uses · Editor forms can request AI-generated copy.
- Tenant page → Freelancer view: renders · Username route branches to freelancer presentation.
- Tenant page → Video view: renders · Username route branches to video-editor presentation.
- Tenant page → Not public: falls back · Hidden portfolios resolve to the access gate.
- Tenant page → Templates pack: maps to · Stored portfolio data selects a template family.
- Freelancer view → Portfolio API: reads · Public portfolio rendering depends on portfolio data.
- Video view → Video API: reads · Video portfolio rendering depends on specialized data.
- Portfolio API → MongoDB: persists · Portfolio CRUD is stored in MongoDB.
- Video API → MongoDB: persists · Video-editor portfolios are stored in MongoDB.
- Analytics API → Analytics model: writes · Analytics events are stored through a dedicated schema.
- Analytics API → MongoDB: stores · Tracking data is persisted in the shared database.
- Media API → MongoDB: stores · Uploaded media metadata is backed by MongoDB.
- AI API → MongoDB: checks quota · AI generation is gated by stored quota/state.
- Payments API → MongoDB: records · Payment and verification state is persisted.
- Referral API → MongoDB: updates · Referral lifecycle data is stored centrally.
- Models → MongoDB: uses · Domain models are built on the shared MongoDB connection.
- Dashboard → Portfolio API: edits via · Dashboard content is saved through portfolio APIs.
- Dashboard → Video API: edits via · Video-editor content is saved through video portfolio APIs.
- Dashboard → Analytics API: inspects · Analytics panel reads aggregated tracking data.
- Dashboard → Referral API: manages · Referral features are exposed inside the dashboard.
- Dashboard → Payments API: pays · Monetization flows begin from the authenticated app.