How thiagotsdelima/ignit-shop works
Project Type and Purpose
• This is a full-stack e-commerce web application built with Next.js.
• The README and file tree show:
• A React-based frontend under src/pages and src/components.
• Serverless API routes in src/pages/api, notably checkout.ts which integrates with Stripe.
• Client-side state management via Context + Reducer (shopCartContext.tsx, shopCartReducer.ts).
• Styling with CSS-in-JS (src/styles).
High-Level Architecture
┌──────────────────┐ ┌────────────────────┐
│ Browser / UX │──────▶│ Next.js SSR │
│(React Components)│ │– Pages & Components│
└──────────────────┘ └────────────────────┘
│ │
│ Client-side cart state │
│ in Context + Reducer │
▼ │
┌──────────────────┐ │
│ HTTP Requests │◀──────────────────┘
│ (e.g. /api/checkout) │
└──────────────────┘ ▼
│ ┌──────────────────┐
│ POST /api/checkout │ Stripe SDK │
▼ │ (create session)│
┌──────────────────┐ └──────────────────┘
│ Next.js Server │
│ API Route Layer │
└──────────────────┘
Main Components
a. Frontend Layer
• React pages (pages/index.tsx, pages/product/[id].tsx, pages/success.tsx)
• Shared UI components (Badge, BagButton, MenuContent, etc.)
• Global styles (src/styles/global.ts, page styles)
• Client-side state: Context (shopCartContext.tsx) + Reducer (shopCartReducer.ts)
b. Backend / Serverless Layer
• Next.js API Routes (pages/api/checkout.ts) hosted as serverless functions
• Stripe integration (src/services/stripe.ts)
c. External Services
• Stripe Checkout (payment processing)
d. Assets & Configuration
• Public assets (public/) for images
• Next.js configuration (next.config.mjs)
• TypeScript config (tsconfig.json)
Relationships & Data Flows
• User interacts with React UI → updates cart context/reducer.
• On “Checkout” click → frontend POST to /api/checkout.
• Next.js serverless function calls Stripe SDK → returns Checkout Session URL.
• Frontend redirects user to Stripe Checkout page → Stripe processes payment.
• Stripe redirects back to /success on payment success.
Architectural Patterns & Principles
• “Separation of Concerns”: UI components vs. business logic (Context/Reducer) vs. payment integration (service + API).
• Serverless functions for backend endpoints → No dedicated server required.
• SSR/SSG features of Next.js for fast page loads.
Technologies & Frameworks (annotate
• Next.js / React
• TypeScript
• Context API + Reducer (state management)
• Stripe Node SDK
• CSS-in-JS (styled-components or equivalent via styles/*.ts)