How kelvinrlq/bella-fatia-pedido-online works
Project type and purpose
• This is a full-stack e-commerce/checkout single-page application (SPA).
• Frontend: built with Vite, React, TypeScript, Tailwind CSS, shadcn-ui components.
• Backend: Supabase (database + auth + storage) plus three edge-functions for PIX payment (generate-pix, check-pix-status, pix-webhook).
File structure
Top-level directories & files:
• public/ – static assets and upload folder for product images.
• src/ – main React application:
· components/ + components/ui/ – reusable UI & business components (Banner, Cart, CheckoutForm, etc.)
· data/ – mock-data for local dev
· hooks/ – custom React hooks (useCart, useMobile, useToast)
· integrations/supabase/ – Supabase client setup & types
· pages/ – React pages/routes (Index, NotFound, StatusPedido)
· main.tsx, App.tsx – entrypoints
• supabase/ – Supabase project config + Functions directory for serverless APIs (TypeScript code under generate-pix, check-pix-status, pix-webhook).
• config files – vite.config.ts, tailwind.config.ts, tsconfig*.json, .eslintrc, package.json
Extract README insights
• Tech stack: Vite, React, TS, shadcn-ui, Tailwind, Supabase.
• Deployment / editing via Lovable platform or local dev.
• No pre-drawn architecture is provided.
Main components
A. Client (Browser / SPA)
– Vite-built React application served as static files (Host: Netlify / Vercel / Supabase Static Hosting)
– UI layers: Pages ←→ Components ←→ UI primitives (shadcn-ui)
B. API Layer (Supabase Edge Functions)
– generate-pix
– check-pix-status
– pix-webhook
These expose REST endpoints under your Supabase project domain.
C. Supabase Backend Services
– Database (PostgreSQL) – stores orders, products, payment records
– Auth – user accounts (if any), session management
– Storage – optional, for uploaded assets under public/lovable-uploads
D. Third-Party Payment Provider
– PIX payment network (calls via generate-pix & receives webhooks)
Relationships & data flows
1. User → Browser/SPA (React)
2. SPA ↔ Supabase Edge Functions (HTTP calls for payment, status checks)
3. Edge Functions ↔ Supabase Database & Storage
4. Payment Provider (PIX) → pix-webhook function → Database update
5. SPA polls check-pix-status or listens for status changes via subscriptions
Architectural patterns & principles
• Single-Page Application (client-heavy UI).
• Micro-frontend style: clear separation of UI components vs. pages vs. hooks vs. data.
• Microservices / serverless: each compliance with one function = one edge-function.
• API-first: ephemeral functions behind REST endpoints.
• Utility layer: src/lib/utils.ts + custom hooks for encapsulation.
• State management: local React state + custom hooks (useCart).
• Theming & styling: Tailwind + shadcn-ui primitives ensure consistent design system.
Essential elements
• Callouts for config files (supabase/config.toml) and environment variables.