# de-freitas/coffee-delivery architecture

> Architecture diagram of the GitHub repository de-freitas/coffee-delivery, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/de-freitas/coffee-delivery
- Repository: https://github.com/de-freitas/coffee-delivery

## Overview

1. **Overall shape**
   - This is a **client-side React single-page application** built with **Vite, TypeScript, and Tailwind CSS**.
   - There is **no backend service** in the repo; the app is fully browser-run and deployed as a static frontend.

2. **App entry and composition**
   - `src/main.tsx` boots the React app.
   - `App.tsx` is the top-level composition point and likely wires together global providers, routing, and layout.
   - Global styles live in `src/index.css` and `src/App.css`, with Tailwind configured alongside them.

3. **Routing boundary**
   - `src/components/Router.tsx` centralizes route definitions.
   - The main routes are:
     - **Home**: coffee catalog and marketing content
     - **Checkout**: cart and order submission flow
     - **Success**: post-order confirmation
     - **Error**: fallback/unknown route handling
   - This is a clear page-level boundary for the architecture diagram.

4. **Layout shell**
   - `src/components/DefaultLayout.tsx` provides the shared page frame around routed content.
   - `src/components/Header.tsx` is the primary shared navigation/branding element.
   - The shared layout separates cross-cutting UI chrome from page-specific screens.

5. **Home subsystem**
   - `src/pages/Home/` contains the landing experience:
     - `home-page.tsx` as the page container
     - `main-section.tsx` for hero/intro content
     - `our-coffees.tsx` for the product listing
   - The Home page is where users discover products and initiate cart actions.

6. **Product card and catalog rendering**
   - `src/components/CoffeeCard.tsx` is the reusable item component for coffee products.
   - Product/catalog data appears to be driven from `src/constants/constants.ts`, which likely holds the coffee list and shared app constants.
   - The catalog is rendered as a list, so this is the main “product data → UI cards” flow.

7. **Cart and application state**
   - `src/contexts/CoffeesContext.tsx` is the core state boundary.
   - The README indicates the app uses **Context API + reducer + immutable state patterns + LocalStorage**.
   - This context likely owns:
     - selected coffees / cart contents
     - item quantities
     - persisted state across refreshes
   - This is the main shared data store for the app.

8. **Checkout subsystem**
   - `src/pages/Checkout/checkout-page.tsx` is the checkout container.
   - Its subcomponents break the flow into distinct concerns:
     - `selected-coffees.tsx` for cart review
     - `address-form.tsx` for shipping details
     - `payment-selection.tsx` for payment method choice
     - `confirm-order.tsx` for final submission
   - This page is the primary consumer of the cart context and the place where order data is assembled.

9. **Success and error states**
   - `src/pages/Success/success-page.tsx` displays the post-checkout confirmation.
   - `src/pages/Error/error-page.tsx` handles invalid routes or failure states.
   - These pages represent terminal outcomes in the user journey rather than interactive catalog flow.

10. **Data transformation utilities**
   - `src/utils/formatPriceToPtBR.ts` formats currency for Brazilian Portuguese conventions.
   - `src/utils/zipCodeMask.ts` handles postal-code input formatting in checkout.
   - These utilities sit at the presentation/input boundary and support localized UX.

11. **State/data flow across the app**
   - The main flow is:
     - user browses coffees on **Home**
     - adds items to the shared **cart context**
     - navigates to **Checkout**
     - enters address/payment details
     - confirms the order
     - lands on **Success**
   - Because state is centralized in context and persisted locally, the app can survive refreshes without a backend.

12. **Technology and deployment boundaries**
   - The stack is explicitly **React + TypeScript + Vite + Tailwind**.
   - `tailwind.config.js`, `postcss.config.js`, and Vite config show a modern frontend build pipeline.
   - Deployment on **Vercel** reinforces that this is a static SPA architecture with client-side routing.

Main entry points: [`src/components/Router.tsx`](https://github.com/de-freitas/coffee-delivery/blob/master/src/components/Router.tsx) (Router), [`src/pages/Checkout/checkout-page.tsx`](https://github.com/de-freitas/coffee-delivery/blob/master/src/pages/Checkout/checkout-page.tsx) (Checkout page), [`src/contexts/CoffeesContext.tsx`](https://github.com/de-freitas/coffee-delivery/blob/master/src/contexts/CoffeesContext.tsx) (Coffee context), [`src/pages/Home/home-page.tsx`](https://github.com/de-freitas/coffee-delivery/blob/master/src/pages/Home/home-page.tsx) (Home page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g1["Shell"]
  node_n1["main<br/>entrypoint<br/>[main.tsx]"]
  node_n2["App<br/>root component<br/>[App.tsx]"]
  node_n3["Router<br/>route map<br/>[Router.tsx]"]
  node_n4["Layout<br/>page shell<br/>[DefaultLayout.tsx]"]
  node_n5["Header<br/>nav chrome<br/>[Header.tsx]"]
end

subgraph group_g2["Home"]
  node_n6["Home page<br/>screen<br/>[home-page.tsx]"]
  node_n7["Main section<br/>landing section<br/>[main-section.tsx]"]
  node_n8["Coffee grid<br/>catalog section<br/>[our-coffees.tsx]"]
  node_n9["Coffee card<br/>product card<br/>[CoffeeCard.tsx]"]
end

subgraph group_g3["Checkout"]
  node_n10["Checkout page<br/>screen<br/>[checkout-page.tsx]"]
  node_n11["Selected coffees<br/>cart review"]
  node_n12["Address form<br/>form section<br/>[address-form.tsx]"]
  node_n13["Payment selection<br/>form section"]
  node_n14["Confirm order<br/>submission step<br/>[confirm-order.tsx]"]
end

subgraph group_g4["State"]
  node_n15[("Coffee context<br/>state store<br/>[CoffeesContext.tsx]")]
  node_n16["Constants<br/>catalog data<br/>[constants.ts]"]
  node_n17["Price format"]
  node_n18["Zip mask<br/>[zipCodeMask.ts]"]
end

subgraph group_g5["Outcome"]
  node_n19["Success page<br/>screen<br/>[success-page.tsx]"]
  node_n20["Error page<br/>screen<br/>[error-page.tsx]"]
end

node_n1 -->|"boots"| node_n2
node_n2 -->|"uses"| node_n3
node_n3 -->|"wraps"| node_n4
node_n4 -->|"contains"| node_n5
node_n3 -->|"home"| node_n6
node_n3 -->|"checkout"| node_n10
node_n3 -->|"success"| node_n19
node_n3 -->|"fallback"| node_n20
node_n6 -->|"composes"| node_n7
node_n6 -->|"composes"| node_n8
node_n8 -->|"renders"| node_n9
node_n8 -->|"reads"| node_n16
node_n9 -->|"updates"| node_n15
node_n10 -->|"composes"| node_n11
node_n10 -->|"composes"| node_n12
node_n10 -->|"composes"| node_n13
node_n10 -->|"composes"| node_n14
node_n10 -->|"reads"| node_n15
node_n11 -->|"reads"| node_n15
node_n12 -->|"uses"| node_n18
node_n14 -->|"formats"| node_n17
node_n19 -->|"reads"| node_n15

click node_n1 "https://github.com/de-freitas/coffee-delivery/blob/master/src/main.tsx"
click node_n2 "https://github.com/de-freitas/coffee-delivery/blob/master/src/App.tsx"
click node_n3 "https://github.com/de-freitas/coffee-delivery/blob/master/src/components/Router.tsx"
click node_n4 "https://github.com/de-freitas/coffee-delivery/blob/master/src/components/DefaultLayout.tsx"
click node_n5 "https://github.com/de-freitas/coffee-delivery/blob/master/src/components/Header.tsx"
click node_n6 "https://github.com/de-freitas/coffee-delivery/blob/master/src/pages/Home/home-page.tsx"
click node_n7 "https://github.com/de-freitas/coffee-delivery/blob/master/src/pages/Home/main-section.tsx"
click node_n8 "https://github.com/de-freitas/coffee-delivery/blob/master/src/pages/Home/our-coffees.tsx"
click node_n9 "https://github.com/de-freitas/coffee-delivery/blob/master/src/components/CoffeeCard.tsx"
click node_n10 "https://github.com/de-freitas/coffee-delivery/blob/master/src/pages/Checkout/checkout-page.tsx"
click node_n11 "https://github.com/de-freitas/coffee-delivery/blob/master/src/pages/Checkout/selected-coffees.tsx"
click node_n12 "https://github.com/de-freitas/coffee-delivery/blob/master/src/pages/Checkout/address-form.tsx"
click node_n13 "https://github.com/de-freitas/coffee-delivery/blob/master/src/pages/Checkout/payment-selection.tsx"
click node_n14 "https://github.com/de-freitas/coffee-delivery/blob/master/src/pages/Checkout/confirm-order.tsx"
click node_n15 "https://github.com/de-freitas/coffee-delivery/blob/master/src/contexts/CoffeesContext.tsx"
click node_n16 "https://github.com/de-freitas/coffee-delivery/blob/master/src/constants/constants.ts"
click node_n17 "https://github.com/de-freitas/coffee-delivery/blob/master/src/utils/formatPriceToPtBR.ts"
click node_n18 "https://github.com/de-freitas/coffee-delivery/blob/master/src/utils/zipCodeMask.ts"
click node_n19 "https://github.com/de-freitas/coffee-delivery/blob/master/src/pages/Success/success-page.tsx"
click node_n20 "https://github.com/de-freitas/coffee-delivery/blob/master/src/pages/Error/error-page.tsx"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_n1,node_n2,node_n3,node_n4,node_n5 toneBlue
class node_n6,node_n7,node_n8,node_n9 toneAmber
class node_n10,node_n11,node_n12,node_n13,node_n14 toneMint
class node_n15,node_n16,node_n17,node_n18 toneRose
class node_n19,node_n20 toneIndigo
```

## Components

### Shell

App bootstrap, routing, and shared chrome

- [main](https://github.com/de-freitas/coffee-delivery/blob/master/src/main.tsx): entrypoint · Bootstraps the React app · `src/main.tsx`
- [App](https://github.com/de-freitas/coffee-delivery/blob/master/src/App.tsx): root component · Top-level composition and providers · `src/App.tsx`
- [Router](https://github.com/de-freitas/coffee-delivery/blob/master/src/components/Router.tsx): route map · Centralizes page routing · `src/components/Router.tsx`
- [Layout](https://github.com/de-freitas/coffee-delivery/blob/master/src/components/DefaultLayout.tsx): page shell · Shared frame around routed content · `src/components/DefaultLayout.tsx`
- [Header](https://github.com/de-freitas/coffee-delivery/blob/master/src/components/Header.tsx): nav chrome · Global branding and navigation · `src/components/Header.tsx`

### Home

Landing and catalog experience

- [Home page](https://github.com/de-freitas/coffee-delivery/blob/master/src/pages/Home/home-page.tsx): screen · Landing page for coffee discovery · `src/pages/Home/home-page.tsx`
- [Main section](https://github.com/de-freitas/coffee-delivery/blob/master/src/pages/Home/main-section.tsx): landing section · Hero and intro content · `src/pages/Home/main-section.tsx`
- [Coffee grid](https://github.com/de-freitas/coffee-delivery/blob/master/src/pages/Home/our-coffees.tsx): catalog section · Renders the coffee listing · `src/pages/Home/our-coffees.tsx`
- [Coffee card](https://github.com/de-freitas/coffee-delivery/blob/master/src/components/CoffeeCard.tsx): product card · Reusable product display and add-to-cart entry point · `src/components/CoffeeCard.tsx`

### Checkout

Cart review and order submission flow

- [Checkout page](https://github.com/de-freitas/coffee-delivery/blob/master/src/pages/Checkout/checkout-page.tsx): screen · Cart review and order flow · `src/pages/Checkout/checkout-page.tsx`
- [Selected coffees](https://github.com/de-freitas/coffee-delivery/blob/master/src/pages/Checkout/selected-coffees.tsx): cart review · Shows items and quantities · `src/pages/Checkout/selected-coffees.tsx`
- [Address form](https://github.com/de-freitas/coffee-delivery/blob/master/src/pages/Checkout/address-form.tsx): form section · Collects shipping details · `src/pages/Checkout/address-form.tsx`
- [Payment selection](https://github.com/de-freitas/coffee-delivery/blob/master/src/pages/Checkout/payment-selection.tsx): form section · Chooses payment method · `src/pages/Checkout/payment-selection.tsx`
- [Confirm order](https://github.com/de-freitas/coffee-delivery/blob/master/src/pages/Checkout/confirm-order.tsx): submission step · Finalizes the checkout · `src/pages/Checkout/confirm-order.tsx`

### State

Shared data, constants, and helpers

- [Coffee context](https://github.com/de-freitas/coffee-delivery/blob/master/src/contexts/CoffeesContext.tsx): state store · Shared cart state and persistence boundary · `src/contexts/CoffeesContext.tsx`
- [Constants](https://github.com/de-freitas/coffee-delivery/blob/master/src/constants/constants.ts): catalog data · Product list and shared app constants · `src/constants/constants.ts`
- [Price format](https://github.com/de-freitas/coffee-delivery/blob/master/src/utils/formatPriceToPtBR.ts): utility · Formats currency for pt-BR · `src/utils/formatPriceToPtBR.ts`
- [Zip mask](https://github.com/de-freitas/coffee-delivery/blob/master/src/utils/zipCodeMask.ts): utility · Masks postal-code input · `src/utils/zipCodeMask.ts`

### Outcome

Terminal user journey pages

- [Success page](https://github.com/de-freitas/coffee-delivery/blob/master/src/pages/Success/success-page.tsx): screen · Shows order confirmation · `src/pages/Success/success-page.tsx`
- [Error page](https://github.com/de-freitas/coffee-delivery/blob/master/src/pages/Error/error-page.tsx): screen · Handles invalid or fallback routes · `src/pages/Error/error-page.tsx`

## Connections

- main → App: boots · Entry point renders the app root
- App → Router: uses · App delegates routing to the router
- Router → Layout: wraps · Routes are rendered inside the shared layout
- Layout → Header: contains · Layout includes the global header
- Router → Home page: home · Home route resolves to the landing page
- Router → Checkout page: checkout · Checkout route resolves to the order flow
- Router → Success page: success · Success route resolves to confirmation
- Router → Error page: fallback · Unknown route resolves to error handling
- Home page → Main section: composes · Home page includes the hero section
- Home page → Coffee grid: composes · Home page includes the catalog section
- Coffee grid → Coffee card: renders · Catalog list is built from reusable cards
- Coffee grid → Constants: reads · Catalog content comes from shared constants
- Coffee card → Coffee context: updates · Cards interact with shared cart state
- Checkout page → Selected coffees: composes · Checkout page shows selected items
- Checkout page → Address form: composes · Checkout page collects address details
- Checkout page → Payment selection: composes · Checkout page collects payment choice
- Checkout page → Confirm order: composes · Checkout page ends in order confirmation action
- Checkout page → Coffee context: reads · Checkout uses the shared cart state
- Selected coffees → Coffee context: reads · Selected coffees reflect context state
- Address form → Zip mask: uses · Address input uses postal-code masking
- Confirm order → Price format: formats · Order totals and prices use locale formatting
- Success page → Coffee context: reads · Success page can summarize the completed order
