How bloodwraith8851/gocart works
Project Type and Purpose
• GoCart is a full-stack, multi-tenant e-commerce platform built on Next.js (App Router), React, Redux Toolkit, Clerk for authentication, Prisma ORM, and PostgreSQL.
• It serves three user roles: Public customers, Store owners (sellers), and Admins, each with its own UI subtree under app/(public), app/store, and app/admin.
File Structure
• Top-level “app” directory is subdivided into:
• (public) – customer-facing pages and layout
• store – seller dashboard, product and order management
• admin – platform administration, store approval, coupons, analytics
• layout.jsx & StoreProvider.js – global wrappers (ClerkProvider, Redux Provider)
• components/ holds reusable UI pieces, grouped further into components/admin/ and components/store/.
• lib/ contains Redux slice definitions (features/*/…Slice.js), store.js factory, and prisma.js for database client.
• prisma/ folder holds the database schema.
• Middleware (middleware.ts) enforces route protection via Clerk.
README for Architectural Insights
a. Main Components
• Frontend
– Public Interface (pages under app/(public))
– Store Owner Interface (app/store/*)
– Admin Interface (app/admin/*)
• Shared Frontend Services
– ClerkProvider for authentication
– Redux Store (Provider from StoreProvider.js) managing slices (cart, product, address, rating)
• Backend/API
– Next.js API routes and server actions in app/api/*
– Middleware for route protection
• Data Layer
– Prisma client (lib/prisma.js)
– PostgreSQL database (schema in prisma/schema.prisma)
• External Services
– Clerk (auth)
– Potential payment gateways (Stripe, COD)
b. Relationships and Interactions
• User action in a UI (Public/Store/Admin) → calls React component → uses Redux selectors or dispatches server actions via Next.js API routes.
• Redux dispatch → Next.js API route → Prisma client → Postgres → back to Redux → UI.
• ClerkProvider wraps the whole app to gate routes, with middleware enforcing protected paths for store/admin.
• StoreProvider instantiates the Redux store once and supplies it to all three interfaces.
c. Architectural Patterns and Principles
• Modular, zone-based UI: each user role has a dedicated sub-app.
• Centralized state management (Redux Toolkit) to decouple UI and data fetching.
• Provider pattern for auth (Clerk) and state (Redux) in app/layout.jsx → StoreProvider.js.
• Layered separation: Presentation (components/pages) → State (slices) → API/middleware → Persistence (Prisma/Postgres).
• Clear folder-per-feature organization for slices and components.
d. Key Technologies and Frameworks
• Next.js App Router for SSR, routing, and API routes.
• React + Redux Toolkit for UI and state.
• Clerk for authentication.
• Prisma ORM + PostgreSQL for data persistence.
• Tailwind CSS for styling.
• React Hot Toast, Recharts, Date-fns for notifications, charts, and date handling.
Detail without Overthinking
• Every major folder/module as its own component or sub-component.
• Three-tier user interface separation, centralized Redux, API boundary, ORM, and persistent store.
• Middleware’s role in protecting routes.