00%
KAWSAR.DEV
HomeSkillsProjectsAboutContribContact
FULL-STACKLIVE 10 min read

NexusMart

NexusMart

Platform Overview & Engineering Intent

NexusMart is a production ready multi vendor marketplace platform engineered to handle complex e commerce operations, role based workflows, and catalog scaling. Built from the ground up to solve typical latency and permission bottlenecks, it decouples client state execution from administrative oversight while maintaining strict type safety across the entire data layer.

The system relies on context based session management, optimized API querying routes, and isolated database schemas. Every action from browsing public catalog items to authorizing vendor submissions passes through explicit validation gates, ensuring high resilience against unauthorized data tampering.

State Management & Data Flow Architecture

Client side reactivity is managed through modular React Context providers combined with Next.js client component routing strategies. This design prevents unnecessary tree re renders when cart modifications or user session updates happen globally.

AuthContext Provider

Persists JSON Web Tokens in secure local storage or cookies, validating user permissions on mount and injecting authorization headers automatically into Axios interceptor calls.

CartContext State

Handles multi item calculations, persistent local storage synchronization, quantity adjustments, and optimistic UI updates during fast user interactions.

Security & Role-Based Access Control (RBAC)

Security is enforced at multiple tiers of the application stack, separating public discovery endpoints from protected administrative domains.

Middleware Authorization Pipeline

Express backend middleware inspects incoming Bearer tokens, extracts user payloads, and validates user roles against required route parameters before executing controller logic.

Submission Moderation Barrier

Vendor product additions are forced into a pending status state. Direct manipulation of database flags is prevented through mongoose schema validation rules and strict controller permission checks.

Performance Optimizations & Database Indexing

To ensure responsiveness under heavy catalog queries, several optimization strategies have been integrated into the database and asset delivery layers.

Database Indexing

MongoDB collection schemas implement text indexes on product titles and categorical fields to optimize search filtering query speeds.

Media Offloading

External image hosting integration through the ImgBB API keeps server payload sizes small and prevents storage bloat on the primary application cluster.

Key System Features

Role Based Dashboards

Separate UI dashboards for Admins and Regular users featuring metric displays, submission statuses, and Recharts visualization analytics.

Moderation System

Items submitted by vendors remain in a pending state until an Admin reviews and approves them for public marketplace availability.

Advanced Search Filters

Real time listing queries utilizing search terms, product categories, and dynamic minimum or maximum price sorting controls.

Flexible Media Engine

Dual image handling supporting direct file uploads via ImgBB API integration or external URL string assignments.

REST API Endpoints Specification

The backend provides a RESTful interface protected by JSON Web Token verification middleware.

RouteMethodActionAccess
/api/auth/registerPOSTRegister new user accountPublic
/api/auth/loginPOSTAuthenticate user credentialsPublic
/api/auth/profileGETFetch active user profileUser
/api/itemsGETRetrieve public approved itemsPublic
/api/items/addPOSTSubmit new product entryUser
/api/items/:id/approvePATCHApprove pending item submissionAdmin
/api/admin/users/:id/rolePATCHToggle user privilege roleAdmin

Repository Directory Architecture

nexusmart-frontend
├── README.md
├── index.html
├── package.json
├── postcss.config.js
├── tailwind.config.js
├── vercel.json
├── vite.config.js
└── src/
    ├── App.jsx
    ├── index.css
    ├── main.jsx
    ├── components/
    │   ├── Footer.jsx
    │   ├── Navbar.jsx
    │   ├── ProtectedRoute.jsx
    │   ├── RoomCard.jsx
    │   └── Spinner.jsx
    ├── context/
    │   ├── AuthContext.jsx
    │   └── ThemeContext.jsx
    ├── pages/
    │   ├── AddRoom.jsx
    │   ├── Home.jsx
    │   ├── Login.jsx
    │   ├── MyBookings.jsx
    │   ├── MyListings.jsx
    │   ├── NotFound.jsx
    │   ├── Register.jsx
    │   ├── RoomDetails.jsx
    │   └── Rooms.jsx
    └── utils/
        └── api.js
nexusmart-backend
├── README.md
├── package.json
├── tsconfig.json
├── .env.example
└── src/
    ├── index.ts
    ├── config/
    │   └── db.ts
    ├── controllers/
    │   ├── adminController.ts
    │   ├── analyticsController.ts
    │   ├── authController.ts
    │   └── itemController.ts
    ├── middleware/
    │   ├── isAdmin.ts
    │   ├── validate.ts
    │   └── verifyToken.ts
    ├── models/
    │   ├── Item.ts
    │   └── User.ts
    ├── routes/
    │   ├── adminRoutes.ts
    │   ├── analyticsRoutes.ts
    │   ├── authRoutes.ts
    │   └── itemRoutes.ts
    ├── scripts/
    │   ├── seed.ts
    │   └── seedRatings.ts
    ├── types/
    │   └── index.ts
    └── utils/
        └── jwt.ts

Environment & Setup Execution

Executing the system locally requires configuring two environment files across the frontend and backend workspace directories.

Frontend Variables (.env)
NEXT_PUBLIC_API_URL=http://localhost:5000/api
NEXT_PUBLIC_IMGBB_API_KEY=your_imgbb_key_here
Backend Variables (.env)
PORT=5000
MONGODB_URI=mongodb://localhost:27017/nexusmart
JWT_SECRET=your_super_secret_jwt_key
JWT_EXPIRES_IN=7d
ADMIN_EMAIL=admin@nexusmart.com
CLIENT_URL=http://localhost:3000
Database Seeding Execution

Run the database seeding script to populate the MongoDB instance with mock product listings and a default platform administrator account.

npm run seed

Challenges Faced While Developing the Project

Building a complex multi vendor marketplace required solving intricate synchronization and authorization problems across the stack.

Complex Role Synchronization

Synchronizing asynchronous authorization updates between MongoDB user records and client session state required custom token revalidation routines to prevent privilege leakage.

Asynchronous Asset Uploads

Handling concurrent product image uploads through external APIs without blocking UI rendering demanded careful error recovery strategies and fallback image handling.

Potential Improvements and Future Plans for the Project

Future updates will focus on expanding payment integrations and improving system performance for larger catalogs.

Stripe Payment Gateway

Integrating direct checkout processing via Stripe webhooks to handle real time transaction verification and automated order receipt generation.

Redis Caching Tier

Introducing an in memory Redis cache for top requested marketplace items to decrease database query load and accelerate API response times.