How andremelzc/ecommerce works
Project type and purpose
• This is a full-stack e-commerce web application built with Next.js (App Router).
• It serves two main user interfaces: a public client storefront under app/(client) and an admin dashboard under app/(admin).
• It implements its backend using Next.js serverless API routes (app/api/*), integrates with a database via lib/db.ts, and connects to external services such as MercadoPago for payments and NextAuth for authentication.
File structure
• Top-level UI layers:
• app/(client)/… — pages, layouts, and components for shoppers (product browsing, cart, checkout, profile).
• app/(admin)/… — pages, layouts, and components for staff (product management, promotions).
• API layer:
• app/api/* — each folder (e.g. productos, cart, auth, mercado-pago) maps to a serverless route (route.ts) handling CRUD and business logic.
• Shared presentation:
• app/components — reusable React UI elements (auth forms, product cards, navbars, drawers).
• app/context — React Contexts managing global state (cart, checkout, products, promotions).
• app/hooks and app/utils — custom hooks and utility functions for data fetching, formatting, side-effects.
• Data access & business logic:
• lib/ — modules for database connectivity (db.ts), PDF or receipt generation (pdf.ts, boleta.ts), and category/product helpers.
• Configuration & assets:
• next.config.ts, tsconfig.json, CSS, public assets, lint/build configs.
README
• Confirms Next.js App Router usage and basic CLI commands.
Detail, not over-complication
– Partition the UI into client vs admin; group shared components.
– Group API routes by domain.
– Clearly show the DB abstraction (lib/db) vs PDF/receipt generator.
– Show state management (Contexts) feeding into UI components.
– Avoid showing every single file; instead, group by logical module.