How sayemimran/resell-hub-client works
1. Overall shape
Resell Hub is a Next.js App Router application that combines the storefront, account areas, and dashboard experiences in one codebase. The repo is organized around route segments in src/app, with reusable UI and domain logic in src/components and shared auth/payment helpers in src/lib.
2. Primary runtime boundary
The visible backend surface is Next.js route handlers under src/app/api, not a separate server app in this tree. The README references Express and MongoDB, but in this repository snapshot the concrete API entry points are the Next route handlers, plus server/client helper modules that encapsulate authentication and payment calls.
3. Authentication subsystem
Auth is centered on Better Auth. The catch-all handler at src/app/api/auth/[...all]/route.js serves the auth endpoints, while src/lib/auth.js, src/lib/auth-client.js, src/lib/clientAuthFetch.js, and src/lib/server/serverAuthFetch.js split auth concerns between browser and server contexts. The login/register pages and forms live under src/app/auth/* and src/components/auths/*.
4. Marketplace storefront
Public commerce flows are split across home, product discovery, category browsing, cart, checkout, and order success routes. The landing page uses home components such as hero, featured products, stats, categories, and trust/social-proof sections. Product listing/detail pages live under src/app/products and src/app/products/[id], with reusable product cards, review sections, and add-to-cart controls in src/components/products.
5. Cart and checkout flow
Cart state is presented in src/app/cart using CartContents and related UI. Checkout is handled by src/app/checkout and src/components/cart/CheckoutForm.jsx, which likely posts to the src/app/api/checkout_sessions/route.js endpoint. That route is the payment boundary that creates Stripe checkout sessions; the success page at src/app/order-success handles the post-payment landing state.
6. Role-based dashboard boundary
The dashboard is segmented by role under src/app/dashboard: buyer, seller, and admin each have their own route subtree and page set. src/app/dashboard/layout.jsx and shared dashboard components provide the shell, navigation, and responsive sidebars, while each role has its own views and data widgets. This is an important architectural boundary: users only see the subset of commerce data relevant to their role.
7. Buyer workspace
The buyer area focuses on post-purchase and personal commerce management: orders, payments, and wishlist. Components like RecentPayments, WishlistPreview, OrdersTable, and buyer dashboard composites suggest that buyer pages are mostly read-oriented, showing order history and account activity rather than product management.
8. Seller workspace
Seller routes cover product creation, listing management, order handling, and seller analytics. The seller component set includes AddProductForm, MyProducts, ManageOrder, SellerOrderCard, and AnalyticsCharts, indicating a workflow where sellers can create/edit inventory, monitor fulfillment, and inspect performance metrics from within their dashboard boundary.
9. Admin workspace
Admin pages are dedicated to platform oversight: analytics, orders, products, and users. Client components such as AdminAnalyticsClient, AdminOrdersClient, UserTable, CategoryPieChart, and AdminProductCard point to a management console that aggregates system-wide data and supports moderation or operational review.
10. Profile and account management
Profile editing is separated into its own route subtree under src/app/profile and src/app/profile/edit/[id]. Supporting components include profile info, avatar, edit form, and password change form, which suggests account maintenance is treated as a distinct domain from marketplace browsing and purchasing.
11. Shared UI and layout system
The app uses a component-driven design system with reusable navigation, footer, dashboard shell, and content cards. src/app/layout.js and src/app/globals.css define the global app shell and styling, while feature components are grouped by domain so the same product, auth, and dashboard primitives can be reused across multiple routes.
12. Data and service integrations
The repo explicitly integrates Stripe for payments and Better Auth for sessions; MongoDB is the intended persistence layer per the README. Client/server fetch helpers suggest the app distinguishes between browser-initiated requests and server-side authenticated requests, which matters for diagramming trust boundaries and data flow between UI, auth, API routes, and external services.
Main entry points: layout.jsx Dashboard · layout.js Next app · page.js Storefront · page.jsx Catalog
Components 29
App router
Next.js route segments and API handlers
- Next app · Top-level App Router application entry and shared shell
src/app/layout.js - Storefront · Public landing and shopping experience
src/app/page.js - Catalog · Product browsing and product detail pages
src/app/products/page.jsx - Cart · Cart review and item summary
src/app/cart/page.jsx - Checkout · Checkout flow and payment handoff
src/app/checkout/page.jsx - Order success · Post-payment landing state
src/app/order-success/page.jsx - Auth routes · Login and registration pages
src/app/auth/login/page.jsx - Auth API · Catch-all authentication endpoint
src/app/api/auth/[...all]/route.js - Checkout API · Creates Stripe checkout sessions
src/app/api/checkout_sessions/route.js - Profile · Account profile viewing and editing
src/app/profile/page.jsx - Dashboard · Shared dashboard layout and role-based subtrees
src/app/dashboard/layout.jsx - Buyer area · Orders, payments, and wishlist views
src/app/dashboard/buyer/page.jsx - Seller area · Inventory, orders, and seller analytics
src/app/dashboard/seller/page.jsx - Admin area · Platform analytics and moderation views
src/app/dashboard/admin/page.jsx
UI components
Reusable feature and layout components
- Site chrome · Global navigation, footer, and app shell components
src/components/navbar/Navbar.jsx - Home UI · Landing page hero, stats, categories, and trust sections
src/components/home/HeroSection.jsx - Product UI · Cards, details, reviews, and add-to-cart controls
src/components/products/ProductCard.jsx - Cart UI · Cart contents and checkout form components
src/components/cart/CartContents.jsx - Dashboard UI · Shared dashboard shell, tables, cards, and overview widgets
src/components/dashboard/DashboardSidebar.jsx - Buyer widgets · Buyer-specific summary cards and history widgets
src/components/dashboard/BuyerDashboardComponents.jsx - Seller widgets · Seller forms, product management, and analytics widgets
src/components/dashboard/sellercomponents/AddProductForm.jsx - Admin widgets · Admin analytics, order, product, and user management widgets
src/components/dashboard/admin/AdminAnalyticsClient.jsx - Profile UI · Profile info, avatar, edit, and password change forms
src/components/profiles/ProfileInfo.jsx - Auth UI · Login and registration forms plus Google sign-in button
src/components/auths/LoginForm.jsx
Shared logic
Auth, fetch, and payment helpers
- Auth helpers · Better Auth client/server configuration and fetch wrappers
src/lib/auth.js - Stripe helper · Stripe integration utilities
src/lib/stripe.js
External services
Third-party systems the app integrates with
- Better Auth · Session and authentication provider
- Stripe · Checkout session and payment provider
- MongoDB · Persistence layer referenced by the project
Connections 28
- Next app → Site chrome: uses · Global shell composes shared navigation and footer
- Next app → Storefront: routes to · App Router serves the storefront at the root path
- Next app → Dashboard: routes to · Shared dashboard shell hosts role-specific sections
- Storefront → Home UI: renders · Landing experience is built from home sections
- Storefront → Catalog: links · Storefront drives users into catalog browsing
- Catalog → Product UI: renders · Catalog pages reuse product cards and details components
- Catalog → Cart: adds to cart · Product actions feed the cart flow
- Cart → Cart UI: renders · Cart page is driven by cart contents UI
- Cart → Checkout: proceeds to · Cart handoff continues into checkout
- Checkout → Checkout API: calls · Checkout form creates a payment session through the route handler
- Checkout API → Stripe: creates session · Server-side payment boundary with Stripe
- Order success → Stripe helper: confirms payment · Success page reflects completed checkout state
- Auth routes → Auth UI: renders · Login and register pages are form-driven
- Auth routes → Auth API: authenticates with · UI flows are backed by the auth route handler
- Auth API → Auth helpers: uses · Route handler delegates to shared auth helpers
- Auth helpers → Better Auth: integrates · Auth stack is centered on Better Auth
- Profile → Profile UI: renders · Profile routes use dedicated account editing components
- Dashboard → Buyer area: contains · Buyer subtree is one role branch under dashboard
- Dashboard → Seller area: contains · Seller subtree is one role branch under dashboard
- Dashboard → Admin area: contains · Admin subtree is one role branch under dashboard
- Dashboard → Dashboard UI: uses · Shared layout and dashboard primitives support all roles
- Buyer area → Buyer widgets: renders · Buyer pages focus on orders, payments, and wishlist widgets
- Seller area → Seller widgets: renders · Seller pages expose product and fulfillment management
- Admin area → Admin widgets: renders · Admin pages expose platform management widgets
- Buyer widgets → MongoDB: reads · Buyer data is backed by persisted commerce records
- Seller widgets → MongoDB: reads/writes · Seller inventory and order management depend on persisted data
- Admin widgets → MongoDB: reads · Admin views aggregate platform data from persistence
- Auth helpers → MongoDB: stores sessions · Auth flows are expected to persist or validate user state