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.
Persists JSON Web Tokens in secure local storage or cookies, validating user permissions on mount and injecting authorization headers automatically into Axios interceptor calls.
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.
Express backend middleware inspects incoming Bearer tokens, extracts user payloads, and validates user roles against required route parameters before executing controller logic.
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.
MongoDB collection schemas implement text indexes on product titles and categorical fields to optimize search filtering query speeds.
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
Separate UI dashboards for Admins and Regular users featuring metric displays, submission statuses, and Recharts visualization analytics.
Items submitted by vendors remain in a pending state until an Admin reviews and approves them for public marketplace availability.
Real time listing queries utilizing search terms, product categories, and dynamic minimum or maximum price sorting controls.
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.
| Route | Method | Action | Access |
|---|---|---|---|
| /api/auth/register | POST | Register new user account | Public |
| /api/auth/login | POST | Authenticate user credentials | Public |
| /api/auth/profile | GET | Fetch active user profile | User |
| /api/items | GET | Retrieve public approved items | Public |
| /api/items/add | POST | Submit new product entry | User |
| /api/items/:id/approve | PATCH | Approve pending item submission | Admin |
| /api/admin/users/:id/role | PATCH | Toggle user privilege role | Admin |
Repository Directory Architecture
├── 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├── 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.tsEnvironment & Setup Execution
Executing the system locally requires configuring two environment files across the frontend and backend workspace directories.
NEXT_PUBLIC_API_URL=http://localhost:5000/api NEXT_PUBLIC_IMGBB_API_KEY=your_imgbb_key_here
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
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.
Synchronizing asynchronous authorization updates between MongoDB user records and client session state required custom token revalidation routines to prevent privilege leakage.
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.
Integrating direct checkout processing via Stripe webhooks to handle real time transaction verification and automated order receipt generation.
Introducing an in memory Redis cache for top requested marketplace items to decrease database query load and accelerate API response times.