How hmad28/next-js-portfolio works
Project type and purpose
• This is a full-stack Next.js 13 application (using the App Router).
• It serves a portfolio site with dynamic pages (/portfolio/[slug]), an admin dashboard (/dashboard), file‐upload endpoints, and persists data to a relational database via Drizzle ORM (backed by Prisma schema).
File structure
• Top-level “app” directory holds all React server and client components, page routes, layouts, and API routes (app/api/.../route.ts).
• The “components” directory contains shared UI components and custom form widgets (inputs, rich‐text editor, tag selector).
• The “lib” directory implements core utilities:
• lib/db/ initializes Drizzle (with prisma/schema.prisma)
• lib/api.ts abstracts API calls
• lib/uploadthing.ts and app/api/uploadthing handle file uploading to Uploadthing (likely S3 under the hood)
• Configuration and build files include next.config.ts, drizzle.config.ts, tsconfig.json, lint/postcss configs, and deployment via Vercel is implied.
README
1. Next.js Frontend (React App)
• Server Components (app/page.tsx, layout.tsx, dynamic pages)
• Client Components (app/components/client.tsx, form widgets)
2. Next.js API Layer (Serverless Functions)
• Portfolio CRUD endpoints (app/api/portfolios/route.ts, [id]/route.ts)
• Uploadthing endpoint (app/api/uploadthing/route.ts)
• File upload handler (app/api/upload/route.ts)
3. Business-Logic / ORM Layer
• Drizzle ORM (configured in drizzle.config.ts)
• Prisma schema (prisma/schema.prisma)
• DB utilities (lib/db/index.ts, lib/db/schema.ts)
4. Database
• PostgreSQL (or MySQL)—the SQL RDBMS backing Drizzle.
5. File Storage Service
• Uploadthing-managed storage (S3 or equivalent)
6. Deployment / CDN
• Vercel (hosting static assets, serverless functions, CDN)
• Browser → Next.js Frontend (SSR or SSG pages)
• Frontend → API Layer (fetch fetches to /api/portfolios, /api/uploadthing)
• API Layer → ORM Layer (Drizzle calls)
• ORM Layer → Database (SQL queries)
• Upload endpoint → Uploadthing → S3 storage → Return file URL
• User-initiated form submissions → API → DB or Storage → Frontend refresh
c. Architectural patterns & design principles
• App Router (Next.js 13) with nested layouts and dynamic routing
• Server Components for data fetching and initial page render
• Client Components for interactivity (forms, rich-text editor, uploads)
• API routes as serverless functions for business logic
• Layered architecture (Presentation → API → ORM → DB)
• Separation of concerns: UI vs. data vs. storage
d. Key technologies/frameworks
• Next.js 13 (App Router, React Server & Client Components)
• Drizzle ORM + Prisma schema for database modeling
• Uploadthing for file uploads (S3 or other object store)
• Vercel hosting and CDN
• TypeScript throughout