How de-freitas/coffee-delivery works
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: Router.tsx Router · checkout-page.tsx Checkout page · CoffeesContext.tsx Coffee context · home-page.tsx Home page
Components 20
Shell
App bootstrap, routing, and shared chrome
Home
Landing and catalog experience
- Home page · Landing page for coffee discovery
src/pages/Home/home-page.tsx - Main section · Hero and intro content
src/pages/Home/main-section.tsx - Coffee grid · Renders the coffee listing
src/pages/Home/our-coffees.tsx - Coffee card · Reusable product display and add-to-cart entry point
src/components/CoffeeCard.tsx
Checkout
Cart review and order submission flow
- Checkout page · Cart review and order flow
src/pages/Checkout/checkout-page.tsx - Selected coffees · Shows items and quantities
src/pages/Checkout/selected-coffees.tsx - Address form · Collects shipping details
src/pages/Checkout/address-form.tsx - Payment selection · Chooses payment method
src/pages/Checkout/payment-selection.tsx - Confirm order · Finalizes the checkout
src/pages/Checkout/confirm-order.tsx
State
Shared data, constants, and helpers
- Coffee context · Shared cart state and persistence boundary
src/contexts/CoffeesContext.tsx - Constants · Product list and shared app constants
src/constants/constants.ts - Price format · Formats currency for pt-BR
src/utils/formatPriceToPtBR.ts - Zip mask · Masks postal-code input
src/utils/zipCodeMask.ts
Outcome
Terminal user journey pages
- Success page · Shows order confirmation
src/pages/Success/success-page.tsx - Error page · Handles invalid or fallback routes
src/pages/Error/error-page.tsx
Connections 22
- 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