How samjamead/better-faster works
Project Type and Purpose
• This is a full-stack, React-based web application built on Next.js (App Router).
• It provides an interface for managing “drills,” “rounds,” and “tests” (likely golf practice data), backed by Supabase (Postgres) for persistence and authentication.
High-Level Architecture Components
a. Client Layer (Browser)
• Next.js pages & React components under app/ and components/
• UI modules: drills, rounds, tests, login, protected layout
• Uses Server Components (for data fetching) and Client Components (forms, tables)
b. Next.js Server Layer
• App Router handlers (server components + layouts)
• API routes in api/get-rounds.ts and api/upsert-rounds.ts
• middleware.ts for auth checks on protected routes
c. Business Logic & Data Access
• Supabase client in lib/supabase/server.ts for server-side DB calls
• Supabase middleware in lib/supabase/middleware.ts for session handling
• Utility functions in lib/utils.ts
• Types in lib/types.ts and types/ for strong typing
d. Database
• Postgres managed by Supabase
• Schema files in z_database-schema/ define tables: drills, drill_shots, etc.
e. Deployment & Infrastructure
• Hosted on Vercel (Next.js platform)
• Static assets under public/
• Config files: next.config.ts, postcss.config.mjs
Component Interactions & Data Flow
• User interacts in browser → Next.js App Router serves React UI (SSR / streaming)
• On data fetch: Server Components call Supabase via server.ts → Postgres
• For mutations:
• Client Components invoke React Server Actions or call Next.js API routes → Supabase
• API routes in api/ folder read/write via Supabase client
• Authentication:
• Sign-in flow uses Supabase Auth; token persisted in cookies by middleware.ts
• Protected pages under app/(protected)/ check session in middleware
Architectural Patterns & Design Principles
• Separation of concerns: UI components vs. data-access layers vs. API handlers
• Next.js App Router conventions (layouts, server/client components)
• Modular feature folders: drills, rounds, tests each have forms, tables, routes
• Type safety: TypeScript, shared types between front/end and back/end
• Reusable UI primitives under components/ui/ (buttons, cards, tables)