How sidedishjob/kuralis works
Project Type and Purpose
• This is a full-stack web application (“furniture register & maintenance”) built with Next.js (App Router) on the front end and Supabase (Postgres, Auth, Storage) on the back end. It offers SSR content, dynamic routes, RESTful API routes, image uploads, and secure auth.
File Structure Highlights
• Top level:
• src/app → Next.js App Router pages and API routes under /api/*.
• components, contexts, hooks → UI components, state management, data-fetch hooks.
• lib → Shared utilities, API fetcher, server-side wrappers, Supabase clients, error handling.
• supabase → SQL migrations.
• Config files: next.config.ts, tailwind.config.mjs, vercel.json, GitHub Actions workflow.
Main Components
a. Frontend (Next.js App)
• App Router (SSR pages, client hydration)
• UI component library (shadcn/ui, Radix UI, Tailwind)
• React Context & Custom Hooks for state & data fetching (SWR)
b. Backend/API
• Next.js API Routes (/src/app/api/.../route.ts)
• Shared business-logic modules in lib/server/* and lib/api/route.ts
c. Database & Storage
• Supabase PostgreSQL: tables for users, furniture, maintenance, metadata (see supabase/migrations)
• Supabase Storage: image upload bucket + CDN
• RLS & Policies for multi-tenant data security
d. Authentication & Email
• Supabase Auth (email/password + OAuth)
• nodemailer for transactional emails (password reset, contact form)
e. CI/CD & Hosting
• GitHub Actions (lint, tests, build, explicit Vercel CLI deploy)
• Vercel for hosting the Next.js app
f. External & Utility Services
• date-fns for cycle calculation
• SWR for client caching
• Zod + React Hook Form for form validation
• GTag analytics, error logging (client and server)
Relationships & Data Flows
• User → Next.js Frontend (SSR/CSR pages)
• Frontend → Next.js API Routes → lib/server → Supabase DB / Storage
• Frontend (SWR/React Query) → Supabase directly (via supabase client hooks) for some data
• Next.js App’s getServerSideProps (SSR) → Supabase to pre-render critical pages
• Next.js API Routes → nodemailer for email sending
• GitHub Actions → Vercel CLI → Vercel Environment
Architectural Patterns & Design Principles
• Separation of Concerns: UI vs data-fetch hooks vs API logic vs DB schema
• Modular Routing: file-based routing for pages and nested API routes
• SSR + Hydration: preloaded furniture list + client filtering
• RLS at the database layer: isolates user data per session
• Shared API layer: lib/api/route.ts standardizes error handling & responses
• Caching or CDN layer between Storage and Frontend
• Analytics & Error Logging flow to any external service (GTag)