How marsx-dev/devhunt works
Project Type & Purpose
• This is a full-stack web application built with Next.js (using the App Router) that serves as a collaborative launching platform for developer tools.
• Core responsibilities:
• Render marketing, blog, tool listing, and user-account pages (SSG/SSR/ISR).
• Expose internal API routes (app/api and pages/api) for actions like login, newsletter signup, comment/upvote notifications, Product Hunt integrations, and ChatGPT.
• Persist data (users, tools, comments, upvotes, etc.) in a Supabase PostgreSQL backend, use Supabase Auth for login (incl. social OAuth), and Supabase Storage/File Upload.
File Structure & Architectural Patterns
• Top-level “app” folder: React server- and client-components following Next.js App Router conventions; directory-based routing for pages and API endpoints under app/api/*/route.ts.
• Legacy /pages/api: additional REST/edge functions.
• components/ + components/ui/: reusable, atomic UI building blocks, following a component-library pattern.
• utils/supabase/services: a thin service layer encapsulating direct Supabase SDK calls (BaseDbService, CacheService, domain services).
• supabase/: dump.sql and config for local DB restore.
• middleware.ts, next.config.js, tailwind.config.js: app-wide policies, build and styling configuration.
Key Architectural Elements
a. Frontend (Next.js App)
• React Server Components handle SSR/SSG where possible.
• Client Components handle interactivity (commenting, upvoting, form submission) using Supabase JS client via React context provider.
• Styling via Tailwind CSS; global CSS in app/globals.css.
b. API Layer
• Internal API Routes:
• Under app/api/*/route.ts for backend logic (runs server-side).
• Under pages/api for supplemental endpoints (ChatGPT proxy, legacy support).
• Services invoked by these routes reside in utils/supabase/services/*.
c. Database & Auth Backend (Supabase)
• PostgreSQL database (tables for users, tools, comments, upvotes, etc.).
• Auth system with Social OAuth (GitHub, Google).
• Storage buckets for images and assets uploaded via UI.
d. External Integrations
• Product Hunt API (ph-dev-tools route).
• ChatGPT via pages/api/chat-gpt.ts.
• Newsletter service via internal API.
e. Hosting & Deployment
• Vercel for frontend & serverless functions.
• Environment variables (NEXT_PUBLIC_SUPABASE_URL, ANON_KEY, SERVICE_ROLE_KEY).
1. Client Browser
2. Next.js Frontend (Vercel Edge / Serverless)
– App Router pages (React Server/Client components)
– API Routes (app/api & pages/api)
3. Supabase Backend
– Auth
– PostgreSQL DB
– Storage
– Realtime listeners (for notifications)
4. External Services
– OAuth Providers (GitHub, Google)
– Product Hunt API
– OpenAI (ChatGPT)
– Newsletter/mail service
5. CI/CD & Hosting (Vercel)
b. Relationships & Data Flow
• Browser ←→ Next.js pages (HTTP/HTTPS)
• Next.js pages/Client components ←→ Supabase JS SDK (via React provider)
• Next.js API routes → Supabase Admin SDK (server-side calls, service role)
• Next.js API routes → External APIs (Product Hunt, ChatGPT)
• Supabase triggers/webhooks → Next.js notification routes (optional)
c. Architectural Patterns
• Server-Side Rendering & Static Generation
• Client-Side Rendering for interactive widgets
• “Service Layer” pattern isolating database calls
• Atomic Design in UI (component library)
• BaaS (Backend-as-a-Service) with Supabase
d. Technology Labels
• Next.js (App Router)
• React Server/Client Components
• Supabase (Auth, Postgres, Storage, Realtime)
• Tailwind CSS
• Vercel (Edge Functions / Serverless)
• External OAuth & Third-Party APIs