How suceavahacks/hackacode works
Project type and purpose
• This is a full-stack web application built with Next.js (App Router) named “Hackacode.”
• It delivers coding challenge pages, user authentication, and CRUD operations on challenges via a Supabase backend.
File structure
• app/ → Next.js App Router directory containing page.tsx, layout.tsx, route.ts files for server-side and client-side rendering.
• components/ → reusable React UI pieces (Navbar, Sidebar, TestCase, etc.).
• utils/ → data-access layer: mutations/queries for user and problem operations, Supabase client and server wrappers.
• schemas/ → TypeScript schemas for validation (problemSchema.ts).
• public/ → static assets and SVG components.
• config files → tailwind.config.ts, next.config.ts, Dockerfile for styling, build, deployment setups.
README
• Minimal content (“Houdy! This is Hackacode!”), so we infer from file names that the core flows are:
• User signup/sign-in via OAuth (GitHub, Google, Slack)
• Protected pages for creating/publishing coding challenges
• Viewing and running test cases on challenges
a. Main components
• Client (Browser)
• Next.js Frontend (React Client Components + Server Components)
• Next.js API Routes / Server Actions (app/auth/callback/route.ts, utils/mutations, utils/queries)
• Supabase Services
– Auth (OAuth providers)
– PostgreSQL Database (problems, users, test cases)
– Storage (if used)
• CDN / Static Asset Hosting (public/ folder)
b. Relationships & data flow
1. Browser requests a page (SSR or SSG) → Next.js Server
2. Next.js Server renders the page, calling Supabase Server library for data fetch
3. Client Components invoke frontend utils/mutations or utils/queries → Next.js API routes or direct Supabase client calls
4. Supabase Auth handles OAuth flows → issues JWT → Next.js middleware.ts validates auth on protected routes
5. Supabase Database returns/query results → Next.js sends JSON responses → Browser updates UI
c. Architectural patterns & design principles
• Next.js App Router separation of Server Components vs Client Components
• Middleware layer for auth enforcement (middleware.ts + utils/supabase/middleware)
• Layered data-access: high-level mutations/queries modules wrap low-level Supabase calls
• Clear separation of concerns: UI (components/), business logic (utils/), data schemas (schemas/)
d. Key technologies & frameworks
• Next.js (React, SSR/SSG, App Router)
• React + Tailwind CSS for styling
• Supabase (Auth, Database, optional Storage)
• TypeScript for type safety
• Docker for containerization