How rez3x/portfolio-rejaka-main works
Project Type and Purpose
• This is a full-stack personal portfolio website built with Next.js (App Router) and TypeScript.
• Purpose: showcase projects, blog, resume; provide interactive features (guestbook, AI chatbot); handle user authentication and content management.
Main Components
a. Frontend (Next.js App)
• UI Components (src/components) – main page, blog, modals, terminal theme, shared controls
• Pages & Layouts (src/app) – homepage, blog pages, resume page, root layout
• Styling & Theming – Tailwind CSS, global CSS, dual theme logic (terminal vs soft)
• State Management – React Context (src/context/UserContext), custom hooks (src/hooks)
b. Backend/API (Next.js Serverless Routes)
• Authentication API – OAuth routes for Google, GitHub, Discord (src/app/api/auth/…)
• Guestbook API – CRUD for guestbook entries (src/app/api/guestbook)
• AI Chatbot API – voidBot endpoint integrating Google Gemini (src/app/api/voidBot)
• Utility Libraries – MongoDB client (src/lib/mongodb), markdown parsers, word filter (src/utils)
c. Data Storage
• MongoDB – collections for users and guestbook entries
• File-Based Content – markdown posts in public/blog/posts for blog articles
d. External Services
• OAuth Providers – Google, GitHub, Discord
• AI Service – Google Gemini API via @google/generative-ai
• CDN & Reverse Proxy – Cloudflare, Nginx
• Process Manager & Monitoring – PM2
e. Infrastructure & Deployment
• Nginx reverse proxy to Node/Next server on port 3000
• PM2 for app process, monitoring, auto-restart
• SSL via Let’s Encrypt
• DNS & caching via Cloudflare
Relationships and Data Flow
• User’s browser requests static assets & pages via CDN (Cloudflare) → Nginx → Next.js server.
• Frontend requests dynamic data:
• Calls API routes (auth, guestbook, voidBot) → Next.js server → interacts with MongoDB or external APIs → returns JSON.
• OAuth flow: browser ↔ OAuth provider ↔ API route ↔ database for session.
• AI Chatbot: frontend sends user prompt → /api/voidBot → Google Gemini API → filtering → response back to UI.
• Blog pages: static generation or SSR reads markdown files from public/blog/posts → renders article pages.
Architectural Patterns & Design Principles
• Separation of concerns: clear split between UI components, API logic, data layer
• “API route-per-feature” microservice style within Next.js
• Static vs dynamic rendering: markdown-backed blog posts served statically, dynamic API for user actions
• Theming abstraction: centralized context/hooks to switch UI themes
• Secure design: OAuth 2.0, cookie-based sessions, input filtering, content moderation pipeline
Technologies & Frameworks
• Frontend: Next.js 14 (App Router), React 18, TypeScript, Tailwind CSS
• Backend: Node.js, Next.js API routes, MongoDB (native driver)
• Auth: OAuth2.0 (Google/GitHub/Discord)
• AI Integration: Google Gemini API
• Utilities: gray-matter, marked for markdown; custom profanity filter, command processor
• Deployment: Nginx, PM2, Cloudflare, Let’s Encrypt