How raselahmed2023/resellhub works
1. Overall shape
ReSell Hub is organized as a Next.js App Router application. The repository is primarily the frontend + route handlers for a second-hand marketplace, with a clear split between public marketplace pages, authentication endpoints, and role-based dashboards.
2. Route structure and page shells
The app uses two major layout boundaries:
- src/app/(mainLayout) for the public storefront
- src/app/dashboard for authenticated, role-specific areas
This makes the architecture easy to diagram as two top-level user experiences sharing the same codebase but different layouts and navigation.
3. Public marketplace experience
The public side includes:
- Home page with featured products, marketplace stats, popular categories, and sustainability messaging
- Products listing and product detail pages
- Categories page
These pages are the discovery layer where buyers browse and evaluate inventory before logging in or purchasing.
4. Authentication and session boundary
Authentication is handled through Better Auth:
- src/app/api/auth/[...all]/route.js exposes the auth API surface
- src/app/api/verify-session/route.js is a dedicated session-check endpoint
- src/lib/auth.js and src/lib/auth-client.js centralize auth setup
This creates a distinct boundary between anonymous browsing and protected app areas.
5. Role-based dashboard architecture
The dashboard is split into three user roles:
- Buyer: orders, payments, profile, wishlist
- Seller: add product, manage products, manage orders, analytics, profile
- Admin: analytics, orders, products, users
src/app/dashboard/layout.js and src/components/dashboard/Sidebar.jsx indicate a shared dashboard shell with role-specific navigation and page content underneath.
6. Seller workflow
Seller pages support the supply side of the marketplace:
- Adding products
- Editing own products
- Managing listings and orders
- Viewing seller analytics
The README’s feature list implies image upload via ImgBB, so product creation likely includes media upload as part of the listing flow.
7. Buyer workflow
Buyer pages focus on purchase tracking and saved items:
- Wishlist management
- Orders
- Payments
- Profile
The checkout flow is split out into dedicated pages under src/app/checkout, with a separate success screen, which suggests a transaction lifecycle that starts from product/cart selection and ends with payment confirmation.
8. Admin workflow
The admin section is built around marketplace governance:
- Product approval/management
- Order oversight
- User management
- Analytics
This implies a moderation boundary where seller-submitted inventory can be reviewed before becoming visible in the public catalog.
9. Data access and secure client calls
src/lib/axiosSecure.js suggests a shared, authenticated HTTP client for protected API calls. In architecture terms, this is the main client-side data access layer used by dashboard and transactional pages to talk to backend services while carrying auth context.
10. External service integration
The README shows the platform depends on a few external systems that materially shape the architecture:
- Stripe for payments
- Better Auth for login and session management
- ImgBB for image hosting
- A backend stack based on Express + MongoDB is referenced in the README, implying the frontend likely consumes a separate API/service layer for marketplace data
11. UI composition and shared presentation
The app uses reusable UI components for the storefront and marketing surface:
- Navbar, Footer, HeroBanner, SustainabilityImpact
- Home-page feature sections such as stats and popular categories
This keeps the public experience modular while the dashboard has its own reusable shell elements.
12. Nonfunctional concerns
The stack emphasizes:
- responsive UI
- animation via Framer Motion
- analytics visualization via Recharts
- search/filter/sort and pagination for browsing efficiency
These are not separate subsystems, but they influence how data is presented and how the marketplace scales in the UI.
13. How the main flows connect
The end-to-end architecture is:
public browsing → authentication/session verification → role-based dashboard → product creation/approval → checkout/payment → order tracking/analytics.
That flow is the core diagram to draw, with auth and secure API access as the central boundary between the public storefront and protected marketplace operations.
Main entry points: app App Router · layout.js Dashboard layout · layout.jsx Main layout · page.jsx Seller area
Components 21
Public storefront
Anonymous marketplace browsing and product discovery
- Main layout · Layout boundary for the public storefront
src/app/(mainLayout)/layout.jsx - Home page · Marketplace landing experience and featured content
src/app/(mainLayout)/page.js - Products · Public product listing and browse experience
src/app/(mainLayout)/products/page.jsx - Product detail · Individual product view for evaluation and purchase flow
src/app/(mainLayout)/products/[id]/page.jsx - Categories · Category-based discovery and navigation
src/app/(mainLayout)/categories/page.jsx - Checkout · Purchase and payment entry point
src/app/checkout/page.jsx - Success · Post-payment completion screen
src/app/checkout/success/page.jsx
Authentication
Login, registration, and session verification boundary
- Auth API · Better Auth endpoint surface for login and session operations
src/app/api/auth/[...all]/route.js - Session verify · Dedicated endpoint for checking authenticated session state
src/app/api/verify-session/route.js - Login · Sign-in entry for protected areas
src/app/login/page.jsx - Register · Account creation entry for new users
src/app/register/page.jsx
Role dashboard
Protected buyer, seller, and admin areas
- Dashboard layout · Shared layout for authenticated role-specific areas
src/app/dashboard/layout.js - Buyer area · Buyer-facing dashboard section for purchase tracking and saved items
src/app/dashboard/buyer/page.jsx - Seller area · Seller-facing dashboard section for listing and order management
src/app/dashboard/seller/page.jsx - Admin area · Admin-facing dashboard section for governance and oversight
src/app/dashboard/admin/page.jsx
Shared UI
Reusable shell and presentation components
- Sidebar · Shared dashboard navigation and role switchboard
src/components/dashboard/Sidebar.jsx - Site shell · Shared storefront header, footer, and hero sections
src/components/Navbar.jsx
Client data
Auth-aware API access and session helpers
- Auth client · Client-side Better Auth configuration and helpers
src/lib/auth-client.js - Auth server · Server-side auth configuration and session logic
src/lib/auth.js - Secure HTTP · Authenticated client used for protected marketplace requests
src/lib/axiosSecure.js
Other components
- App Router · Top-level application structure and route composition
src/app
Connections 29
- App Router → Main layout: routes · Public route subtree
- App Router → Dashboard layout: routes · Protected dashboard subtree
- App Router → Checkout: routes · Checkout route subtree
- App Router → Auth API: routes · Auth API subtree
- App Router → Login: routes · Login page route
- App Router → Register: routes · Registration page route
- Main layout → Home page: contains · Landing page in public shell
- Main layout → Products: contains · Catalog listing in public shell
- Main layout → Product detail: contains · Product detail in public shell
- Main layout → Categories: contains · Category browsing in public shell
- Home page → Site shell: uses · Shared marketing UI sections
- Products → Site shell: uses · Shared storefront UI
- Dashboard layout → Sidebar: uses · Shared dashboard navigation
- Dashboard layout → Buyer area: contains · Buyer role subtree
- Dashboard layout → Seller area: contains · Seller role subtree
- Dashboard layout → Admin area: contains · Admin role subtree
- Buyer area → Secure HTTP: calls · Protected data requests
- Seller area → Secure HTTP: calls · Protected marketplace operations
- Admin area → Secure HTTP: calls · Protected moderation and analytics calls
- Auth API → Auth server: uses · Server auth implementation
- Login → Auth client: uses · Client sign-in flow
- Register → Auth client: uses · Client sign-up flow
- Session verify → Auth server: uses · Session verification logic
- Dashboard layout → Session verify: guards · Protected-area session check
- Checkout → Secure HTTP: calls · Payment and order submission
- Success → Checkout: follows · Completion step after checkout
- Buyer area → Checkout: enters · Buyer purchase lifecycle
- Seller area → Home page: supplies · Listings feed the public catalog
- Admin area → Seller area: oversees · Moderation and governance over seller inventory