# kelvinrlq/bella-fatia-pedido-online architecture

> Architecture diagram of the GitHub repository kelvinrlq/bella-fatia-pedido-online, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kelvinrlq/bella-fatia-pedido-online
- Repository: https://github.com/kelvinrlq/bella-fatia-pedido-online

## Overview

##### 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.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer" 
        direction TB
        Browser["Browser / SPA: React (TypeScript, Vite, shadcn-ui, Tailwind)"]:::frontend
        subgraph "Entrypoints & Routing"
            direction TB
            Main["main.tsx"]:::frontend
            App["App.tsx"]:::frontend
            IndexPage["Index.tsx"]:::frontend
            StatusPage["StatusPedido.tsx"]:::frontend
            NotFoundPage["NotFound.tsx"]:::frontend
        end
        subgraph "UI Components"
            direction TB
            Banner["Banner"]:::frontend
            CartCmp["Cart"]:::frontend
            CheckoutForm["CheckoutForm"]:::frontend
            CategoryMenu["CategoryMenu"]:::frontend
            Header["Header"]:::frontend
            MobileMenu["MobileMenu"]:::frontend
            ProductCard["ProductCard"]:::frontend
            ProductList["ProductList"]:::frontend
        end
        subgraph "Utilities & Hooks"
            direction TB
            MockData["mock-data.ts"]:::frontend
            UseCart["use-cart"]:::frontend
            UseMobile["use-mobile"]:::frontend
            UseToast["use-toast"]:::frontend
            SupaClient["supabase client"]:::frontend
            SupaTypes["supabase types"]:::frontend
            Utils["utils.ts"]:::frontend
        end
    end

    %% Static Hosting
    subgraph "Static Hosting Layer"
        direction TB
        CDN["CDN / Static Host"]:::external
    end

    %% API Layer
    subgraph "API / Edge Functions" 
        direction TB
        GenPix["generate-pix"]:::functions
        CheckPix["check-pix-status"]:::functions
        PixWebhook["pix-webhook"]:::functions
    end

    %% Data Layer
    subgraph "Supabase Data Layer"
        direction TB
        DB["PostgreSQL Database"]:::data
        Auth["Auth Service"]:::data
        Storage["Storage"]:::data
    end

    %% External Services
    subgraph "External Services"
        direction TB
        PIX["PIX Payment Network"]:::external
    end

    %% Data Flows
    Browser -->|"GET static files (SPA)"| CDN
    CDN --> Browser
    Browser -->|"POST /generate-pix"| GenPix
    Browser -->|"GET /check-pix-status"| CheckPix
    GenPix -->|"INSERT order/payment"| DB
    GenPix -->|"STORE assets (optional)"| Storage
    CheckPix -->|"SELECT status"| DB
    PIX -->|"Webhook POST"| PixWebhook
    PixWebhook -->|"UPDATE status"| DB
    DB -->|"Realtime subscription"| Browser

    %% Click Events
    click Main "https://github.com/kelvinrlq/bella-fatia-pedido-online/blob/main/src/main.tsx"
    click App "https://github.com/kelvinrlq/bella-fatia-pedido-online/blob/main/src/App.tsx"
    click IndexPage "https://github.com/kelvinrlq/bella-fatia-pedido-online/blob/main/src/pages/Index.tsx"
    click StatusPage "https://github.com/kelvinrlq/bella-fatia-pedido-online/blob/main/src/pages/StatusPedido.tsx"
    click NotFoundPage "https://github.com/kelvinrlq/bella-fatia-pedido-online/blob/main/src/pages/NotFound.tsx"
    click Banner "https://github.com/kelvinrlq/bella-fatia-pedido-online/blob/main/src/components/Banner.tsx"
    click CartCmp "https://github.com/kelvinrlq/bella-fatia-pedido-online/blob/main/src/components/Cart.tsx"
    click CheckoutForm "https://github.com/kelvinrlq/bella-fatia-pedido-online/blob/main/src/components/CheckoutForm.tsx"
    click CategoryMenu "https://github.com/kelvinrlq/bella-fatia-pedido-online/blob/main/src/components/CategoryMenu.tsx"
    click Header "https://github.com/kelvinrlq/bella-fatia-pedido-online/blob/main/src/components/Header.tsx"
    click MobileMenu "https://github.com/kelvinrlq/bella-fatia-pedido-online/blob/main/src/components/MobileMenu.tsx"
    click ProductCard "https://github.com/kelvinrlq/bella-fatia-pedido-online/blob/main/src/components/ProductCard.tsx"
    click ProductList "https://github.com/kelvinrlq/bella-fatia-pedido-online/blob/main/src/components/ProductList.tsx"
    click MockData "https://github.com/kelvinrlq/bella-fatia-pedido-online/blob/main/src/data/mock-data.ts"
    click UseCart "https://github.com/kelvinrlq/bella-fatia-pedido-online/blob/main/src/hooks/use-cart.tsx"
    click UseMobile "https://github.com/kelvinrlq/bella-fatia-pedido-online/blob/main/src/hooks/use-mobile.tsx"
    click UseToast "https://github.com/kelvinrlq/bella-fatia-pedido-online/blob/main/src/hooks/use-toast.ts"
    click SupaClient "https://github.com/kelvinrlq/bella-fatia-pedido-online/blob/main/src/integrations/supabase/client.ts"
    click SupaTypes "https://github.com/kelvinrlq/bella-fatia-pedido-online/blob/main/src/integrations/supabase/types.ts"
    click Utils "https://github.com/kelvinrlq/bella-fatia-pedido-online/blob/main/src/lib/utils.ts"
    click GenPix "https://github.com/kelvinrlq/bella-fatia-pedido-online/blob/main/supabase/functions/generate-pix/index.ts"
    click CheckPix "https://github.com/kelvinrlq/bella-fatia-pedido-online/blob/main/supabase/functions/check-pix-status/index.ts"
    click PixWebhook "https://github.com/kelvinrlq/bella-fatia-pedido-online/blob/main/supabase/functions/pix-webhook/index.ts"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef functions fill:#90EE90,stroke:#000,stroke-width:1px
    classDef data fill:#FFA500,stroke:#000,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:1px
```
