Loading…
Loading…
Cyber Mart is a production-focused software project built by Sadam Hussain using Next.js, TypeScript, Node.js, and related technologies.
Multi-vendor marketplace on Next.js and Node.js/Express: MySQL for transactions, MongoDB for catalog content, per-route rendering (SSR/ISR/CSR), hardened checkout. Outcome: full-stack ownership, from index strategy to checkout.
Tech Stack



Status
Production Ready
Type
Enterprise platform
Developed the marketplace frontend with Next.js, implementing a per-route rendering strategy (SSR for product pages, ISR for category listings, CSR for cart/checkout) to optimize both performance and SEO across different page types.
Built a modular Node.js/Express.js backend with layered middleware architecture - authentication, request validation, rate limiting, error handling - supporting high-traffic product browsing and transactional checkout workflows.
Designed a polyglot database architecture combining MySQL (for orders, inventory, and vendor relationships requiring ACID compliance) with MongoDB (for flexible product content and vendor profiles), choosing each database for its strengths rather than forcing one to do everything.
Optimized MySQL query performance through strategic composite indexing, query plan analysis, and schema normalization, targeting the highest-frequency queries (product search, inventory checks, order history) for measurable improvement.
Integrated third-party payment processors and inventory management providers via secure REST API endpoints with versioned contracts, webhook-based event handling, and idempotency keys for financial transaction safety.
Created responsive UI components with Material UI and Tailwind CSS, building a checkout flow with progressive disclosure to reduce cognitive load and cart abandonment.
Implemented comprehensive form validation using React Hook Form with schema-based validation, providing real-time inline feedback and reducing form submission errors across registration, checkout, and vendor onboarding flows.
Integrated SWR for client-side data fetching with stale-while-revalidate caching, enabling real-time inventory and pricing updates without full page reloads during active shopping sessions.
Configured CI/CD pipelines with automated Jest test suites, Docker image builds, and staged AWS deployments, ensuring repeatable, zero-downtime production releases.
Implemented structured error handling and logging across the full stack, with middleware-level error categorization (validation errors, upstream service failures, database errors) for systematic root-cause analysis in production.
Cyber Mart is a multi-vendor marketplace built around the central tension of e-commerce: flexible catalogs and strict transactions. MySQL owns orders, inventory, and payments with ACID guarantees; MongoDB owns product content where schemas vary by vendor. Next.js renders per route: SSR for product pages, ISR for categories, client-side for checkout.
Designed for high-traffic production workloads, the platform enables hundreds of merchants to manage inventory while providing shoppers with a low-latency, SEO-optimized discovery and checkout journey. The architecture treats performance as a full-stack concern - from database indexing strategies through API response shaping to rendering strategy selection on the frontend.
The e-commerce landscape requires a delicate balance between visual richness and technical speed. Every additional millisecond of load time directly impacts conversion rates, and every inconsistency in inventory data erodes user trust.
The core problem: Multi-vendor marketplaces face a unique tension - vendor catalogs grow unpredictably in both size and schema complexity (different product types have different attributes), but transactional workflows (cart, checkout, payment) demand strict consistency. A single-database approach either sacrifices flexibility for transactions or transactions for flexibility.
Stakeholder perspective:
Constraints that shaped the architecture:
The decision to use both MySQL and MongoDB wasn't about using trendy technology - it was about matching data characteristics to database strengths.
MySQL handles transactional data: Orders, payments, and inventory require ACID transactions. When a shopper completes checkout, the system must atomically decrement inventory, create an order record, and record the payment - all within a single transaction. If any step fails, everything rolls back. This is MySQL's core strength.
MongoDB handles catalog content: Product listings from different vendors have wildly different attribute schemas. A laptop listing includes specs (CPU, RAM, storage, display) while a t-shirt listing includes fit, fabric, and color options. In MySQL, this would require either an extremely wide table (mostly NULL columns) or an EAV pattern that makes queries complex and slow. MongoDB's document model stores each product's attributes naturally as nested JSON, and schema validation at the application layer ensures data quality without rigid database constraints.
The join layer: The API layer handles cross-database reads by fetching transactional data from MySQL and content data from MongoDB, merging them into unified response objects. Product IDs serve as the correlation key. This approach keeps each database focused on what it does best.
The backend follows a strict middleware pipeline where each layer has a single responsibility:
This pipeline means route handlers focus purely on business logic - they never handle auth, validation, or error formatting directly.
Performance optimization in Cyber Mart spans every layer:
The most impactful technical challenge was optimizing MySQL query performance for product search across a growing multi-vendor catalog.
The Problem: Product search queries filter across multiple dimensions simultaneously - category, price range, vendor, availability, ratings. The initial schema used single-column indexes, which forced MySQL to choose one index per query and scan the remaining filters row-by-row. As the catalog grew, search response times degraded noticeably.
The Analysis Process: Rather than guessing at index strategies, I analyzed actual query patterns from application logs - which filter combinations were most common, which queries took the longest, and which pages had the most traffic. The 80/20 pattern was clear: category + price range filtering accounted for the majority of search queries, followed by vendor-specific listing views.
The Optimization Approach:
Composite Indexes Aligned to Query Patterns: Created composite indexes that match the most frequent WHERE clause combinations. A composite index on (category_id, price, availability_status) serves the primary search pattern far more efficiently than three separate single-column indexes, because MySQL can use the entire index for a "category X, price between Y and Z, in stock" query in a single B-tree traversal.
Covering Indexes for High-Frequency Reads: For the product listing view (which only needs title, price, thumbnail, vendor name), created covering indexes that include all needed columns. This allows MySQL to serve the query entirely from the index without touching the table data pages - eliminating random disk reads.
Schema Normalization for Write Integrity, Denormalization for Read Performance: Kept the canonical schema normalized for write consistency, but added carefully managed denormalized columns (like cached vendor name on the product table) for read-heavy views where the join cost was measurable. Updates to the denormalized columns are handled through application-level triggers on vendor profile updates.
Query Plan Verification: Every index change was validated with EXPLAIN ANALYZE to confirm that MySQL's query planner actually uses the new index and that the estimated row scan count dropped. Indexes that the planner ignored (due to low cardinality or unfavorable statistics) were removed to avoid write overhead.
Why this matters: Database performance optimization is often treated as DBA work separate from application development. In practice, the most impactful optimizations come from understanding how the application actually queries data - what the frontend needs, how the API shapes requests, and what the typical user journey looks like - then designing indexes and schemas that serve those patterns specifically.
Challenge: Product catalogs from different vendors had fundamentally different attribute schemas, making a single relational model either too rigid or too sparse. Approach: Adopted a polyglot data architecture - MySQL for transactional data requiring ACID compliance (orders, payments, inventory), MongoDB for flexible product content where schema evolution is frequent and attributes vary by product type. Why: Forcing heterogeneous product attributes into a relational schema leads to either wide tables with mostly NULL columns or EAV patterns that make queries complex and slow. MongoDB's document model handles schema flexibility naturally, while MySQL's transaction support is non-negotiable for financial data.
Challenge: Inventory and pricing data displayed to shoppers could become stale between page load and checkout, leading to frustration (item shows "in stock" but fails at checkout). Approach: Implemented SWR with short revalidation intervals for inventory-critical data, and added a final stock check within the checkout transaction that revalidates availability before processing payment. Why: True real-time inventory display (WebSocket-pushed updates) would be over-engineered for an e-commerce catalog. SWR's stale-while-revalidate pattern provides "fresh enough" data for browsing, while the transactional check at checkout ensures correctness where it matters most.
Challenge: Third-party payment processor and inventory provider APIs had different reliability characteristics - timeout rates, error formats, retry semantics. Approach: Built provider-specific adapter layers behind a common interface, with per-provider circuit breakers, retry configurations, and error normalization. Payment operations include idempotency keys to prevent double-processing on retries. Why: Wrapping all third-party APIs in the same generic error handler ignores that a payment timeout requires different handling than an inventory sync failure. Provider-specific adapters can implement the nuanced retry and fallback logic each integration requires.
Challenge: Search response times degraded as the product catalog grew, with complex filter queries scanning more rows than acceptable. Approach: Analyzed actual query patterns from application logs, designed composite indexes aligned to the highest-frequency filter combinations, and verified each optimization with EXPLAIN ANALYZE to confirm index usage. Why: Index optimization based on theoretical query patterns often misses. The most impactful optimizations come from instrumenting actual usage and targeting the queries that real users execute most frequently.
Cyber Mart underscored the critical intersection between data modeling and user experience. In e-commerce, the strongest gains don't come from the UI alone - they come from solving the full-stack problem: from how the database is indexed, to how the API shapes responses, to how the frontend renders and caches data. Performance is additive across layers, and optimizing any single layer in isolation misses the compounding effect.
Patterns I'd reuse:
What I'd reconsider:
Trade-offs acknowledged: