Amr Naseem
Download CV
Cartly

Case Study

Cartly

A modern e-commerce platform featuring secure authentication, Stripe payments, admin management, coupons, order processing, and a scalable full-stack architecture.

Problem

Many small and medium-sized businesses need an affordable e-commerce solution that combines excellent user experience with secure authentication, reliable payment processing, and an intuitive administration dashboard. Existing solutions are often expensive, difficult to customize, or overloaded with unnecessary complexity.

Solution

Cartly was built as a production-ready e-commerce platform using the Next.js App Router. It combines Server Components, Server Actions, Better Auth, MongoDB, and Stripe to provide a fast, secure, and maintainable shopping experience while offering administrators complete control over products, categories, orders, coupons, and inventory.

Features

Email/Password authentication
Google OAuth authentication
Role-based authorization (User, Admin, Super Admin)
Product search
Shopping cart management
Coupon and discount system
Stripe Checkout integration
Order history
Product reviews and ratings
Product management
Coupon management
Order management
Database seeding with realistic demo data

Tech Stack

Next.jsReactTypeScriptTailwind CSSMongoDBMongooseBetter AuthStripeZustand

Technical Decisions

Next.js App Router & Server Components

Used the App Router to leverage Server Components for efficient rendering and Server Actions for secure server-side mutations, reducing unnecessary client-side JavaScript while keeping the architecture scalable.

Better Auth for Authentication

Selected Better Auth to implement secure session management, Google OAuth, email/password authentication, and role-based authorization while keeping authentication logic centralized and type-safe.

Stripe Checkout with Webhooks

Implemented Stripe Checkout together with webhook verification to ensure orders are only created after successful payment confirmation, preventing inconsistencies caused by interrupted client-side payment flows.

MongoDB + Mongoose

Used MongoDB for flexible document storage and Mongoose for schema validation, relationships, indexing, and maintainable data models suitable for a growing e-commerce application.

Reusable Component Architecture

Designed reusable UI components and modular server-side logic to improve maintainability, simplify future feature development, and encourage code reuse across the application.

Challenges & Solutions

Guaranteeing data consistency during the checkout process.

Integrated Stripe webhooks so orders are only persisted after Stripe confirms payment success, avoiding duplicate or incomplete orders caused by client-side interruptions.

Designing scalable authentication and authorization.

Built authentication with Better Auth and implemented role-based access control to securely protect admin routes, dashboard features, and server-side operations.

Generating realistic development data.

Created a complete database seeding system that automatically generates users, categories, products, and coupons, allowing the application to be tested immediately after setup.

Maintaining a clean and scalable codebase.

Separated business logic, database operations, reusable components, and server actions into modular layers to keep the project organized and easy to extend.

Screenshots

16

Future Improvements

  • Advanced product filtering and sorting
  • Product recommendation engine
  • Email notifications
  • Sales analytics dashboard
  • Inventory insights
  • Multi-language support
  • Multi-currency support
  • AI-powered product recommendations