How yuberley/sport-wear-shop works
Project type and purpose
• This is a full-stack Next.js (React) web application, bootstrapped with create-next-app.
• It offers both a public client site (product catalog, categories, contact form, promotions) and an authenticated dashboard (product management, configurations, reports).
• It uses Supabase as its backend (database, auth, storage) and deploys on Vercel.
File structure
• Top-level files: configuration (next.config.mjs, tsconfig.json, tailwind.config.ts, .eslintrc.json, .prettierrc), environment template (.env.example), package.json.
• public/: static assets.
• src/app/: Next.js App Router routes and layouts.
• /login, /auth/callback, /dashboard, /categories, /product, /[itemType]/[category], /contact, /promotions.
• Each folder contains page.tsx or route.ts for serverless API endpoints.
• src/lib/supabase/: Supabase client initialization, API handlers (handleProducts, handleCategories, etc.), salesApi.
• src/hooks, src/utils, src/constants, src/interfaces: utility modules and type definitions.
• src/providers.tsx: React Context/provider wrappers for theming, auth, or data.
README
• Confirms Next.js, how to run locally, links to docs.
a. Main components
• Browser (Client) – user’s web browser
• Next.js Frontend – React components and pages (src/app + src/components)
• Next.js API Routes – serverless functions (e.g. /auth/callback/route.ts)
• Supabase Backend – Auth service, PostgreSQL database, Storage
• Utility modules – hooks, utils, constants, interfaces
• External services – Vercel (hosting & CDN), Google Fonts
b. Relationships & interactions
1. User → Browser → Next.js Frontend (UI rendering, hydration)
2. Frontend → API Routes (fetch REST/JSON) for actions (login callback, CRUD)
3. API Routes (src/lib/supabase/handlers) → Supabase client → Database / Auth / Storage
4. Data ↔ Next.js getServerSideProps or server components (page.tsx) → UI
5. Providers wrap the app to supply auth state, theme, and routing context
c. Architectural patterns & design principles
• Front/Back separation via App Router + API routes
• Component-based UI (atoms, molecules, pages)
• Single responsibility: each handler manages one table (products, categories…)
• Layered modules: presentation (components), domain (interfaces, utils), data-access (lib/supabase)
d. Key technologies/frameworks
• Next.js 13+ (App Router, server components, layouts)
• React + TypeScript
• Supabase (PostgreSQL, Auth, Storage)
• Tailwind CSS for styling
• Vercel for deployment
Detailed breakdown of components
• Frontend Layer:
• “App Router” (src/app/layout.tsx)
• Public pages: Home (/), Product listing (/product), Item categories (/[itemType]), Contact (/contact), Promotions (/promotions)
• Auth flow: Login pages & callback route
• Dashboard pages: /dashboard, /dashboard/products, /dashboard/configurations, /dashboard/reports
• UI components: Header, SideNav, tables, cards
• API Layer:
• Auth callback route (src/app/auth/callback/route.ts)
• Supabase handlers: handleProducts, handleCategories, handleSizes, handleColors, handleImages
• salesApi (for reports queries)
• Data Layer (Supabase):
• Auth service (sign-in, session management)
• Storage bucket (images)
Final recommendations
• Data flows: e.g., “Fetch /api/products → returns JSON → UI ListProducts”.