CodeBook | E-Commerce Platform - React, AWS (Lambda, DynamoDB, S3, HTTP API Gateway) Serverless Architecture FullStack Project (including Admin Panel with Product Management, Analytics, User Management, Order Processing, Review Moderation, Activity Logging)
CodeBook is a modern, full-stack e-commerce platform built with React and AWS serverless architecture for selling computer science eBooks. It features a complete customer storefront with product browsing, shopping cart, Stripe payment integration, order management, and reviews, plus a comprehensive admin dashboard for managing products, orders, users, analytics, and support tickets. The platform uses AWS Lambda, API Gateway, and DynamoDB for scalable serverless backend operations, integrates Cloudinary for images, Brevo for emails, and Shippo for shipping labels, and implements JWT-based authentication with role-based access control. Built with production-ready patterns, responsive Tailwind CSS design, and modern React practices including React Query, CodeBook serves as both a functional e-commerce solution and an educational resource demonstrating real-world full-stack development.
- Live-Demo: https://codebook-aws.vercel.app/
- Project Overview
- Architecture Overview
- Key Features
- Technology Stack
- Project Structure
- Quick Start Guide
- Environment Variables
- Installation & Setup
- Running the Project
- Deployment
- Documentation Links
- Project Architecture
- API Endpoints
- Component Reusability
- Code Examples
- Keywords
- Contributing
- Conclusion
CodeBook is a modern, full-stack e-commerce platform built with React and AWS serverless architecture. It demonstrates production-level patterns for building scalable web applications with authentication, payment processing, admin dashboards, analytics, and comprehensive order management.
- β Production-Ready: Real-world patterns, error handling, and optimizations
- β Serverless Architecture: AWS Lambda + API Gateway + DynamoDB
- β Modern React: Hooks, Context API, React Query for state management
- β Complete E-Commerce: Products, Cart, Checkout, Orders, Reviews, Tickets
- β Admin Dashboard: Analytics, user management, order processing
- β Third-Party Integrations: Stripe, Cloudinary, Brevo, Shippo
- β Responsive Design: Mobile-first with Tailwind CSS
- β Type Safety: Explicit TypeScript types throughout
- β Educational: Well-documented code with learning-focused structure
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend (React) β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Pages β β Components β β Hooks β β
β β β β β β β β
β β - Home β β - UI Cards β β - useQuery β β
β β - Products β β - Forms β β - useAuth β β
β β - Cart β β - Tables β β - useCart β β
β β - Admin β β - Layouts β β - ... β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β
β Deployed on: Vercel β
βββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββ
β
β HTTPS Requests
β
βββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββ
β AWS API Gateway (HTTP API) β
β β
β Routes requests to appropriate Lambda functions β
βββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββΌββββββββββββββββ
β β β
βββββββββΌβββββββ ββββββββΌβββββββ ββββββββΌβββββββ
β Products β β Orders β β Auth β
β Lambda β β Lambda β β Lambda β
βββββββββ¬βββββββ ββββββββ¬βββββββ ββββββββ¬βββββββ
β β β
βββββββββββββββββΌββββββββββββββββ
β
ββββββββββββΌβββββββββββ
β AWS DynamoDB β
β β
β - products β
β - orders β
β - users β
β - reviews β
β - tickets β
β - activity-log β
βββββββββββββββββββββββ- Product Browsing: Search, filter, and browse products with detailed views
- Shopping Cart: Persistent cart with stock validation and quantity management
- Authentication: Secure JWT-based login/registration with role-based access
- Checkout: Stripe Payment Element integration for secure payments
- Order Management: Order history, tracking, and status updates
- Product Reviews: 5-star rating system with review moderation
- Support Tickets: Create and manage support tickets with email notifications
- Dashboard: Business insights with revenue charts and analytics
- Product Management: Full CRUD with image upload, stock management, QR codes
- Order Processing: Update status, process refunds, generate shipping labels
- User Management: View, edit, and manage user accounts
- Review Moderation: Approve/reject product reviews
- Activity Logging: Comprehensive activity tracking and audit logs
- Analytics: Sales trends, top products, user analytics
- React 19.2.0 - UI library
- React Router DOM 7.9.6 - Routing
- TanStack React Query 5.90.10 - Server state & caching
- Tailwind CSS 3.4.1 - Styling
- ShadCN UI - Component library
- Recharts 3.5.1 - Charts
- React Toastify - Notifications
- AWS Lambda - Serverless functions (Node.js 22.x)
- AWS API Gateway - HTTP API
- AWS DynamoDB - NoSQL database
- JWT - Authentication
- bcryptjs - Password hashing
- Stripe - Payment processing
- Cloudinary - Image storage
- Brevo - Email service
- Shippo - Shipping labels
codebook-ecommerce/
β
βββ codebook/ # Main React application
β βββ src/
β β βββ components/ # Reusable components
β β β βββ Elements/ # Core UI elements
β β β βββ Layouts/ # Layout components
β β β βββ ui/ # ShadCN UI components
β β β βββ Sections/ # Page sections
β β βββ pages/ # Page components
β β β βββ Admin/ # Admin pages
β β β βββ Cart/ # Cart pages
β β β βββ Home/ # Homepage
β β β βββ Products/ # Product pages
β β β βββ Tickets/ # Support tickets
β β βββ hooks/ # Custom React hooks
β β βββ services/ # API service layer
β β βββ context/ # React Context providers
β β βββ utils/ # Utility functions
β β βββ routes/ # Route definitions
β βββ aws-lambda/ # AWS Lambda backend
β β βββ functions/ # Lambda function handlers
β β β βββ products/ # Product endpoints
β β β βββ orders/ # Order endpoints
β β β βββ auth/ # Authentication
β β β βββ admin/ # Admin endpoints
β β β βββ payment/ # Stripe integration
β β β βββ ... # Other endpoints
β β βββ shared/ # Shared utilities
β β βββ template.yaml # AWS SAM template
β β βββ deploy.sh # Deployment script
β βββ public/ # Static assets
β βββ data/ # Mock data (db.json)
β βββ README.md # Detailed frontend docs
β
βββ codebook-backend-serverless-json-server-archived-reference/
β βββ backend-mock-json-server-project-reference/
β β βββ README.md # Archived mock server docs
β βββ backend-vercel-serverless-functions-project-reference/
β βββ api/README.md # Archived Vercel functions docs
β
βββ README.md # This file (root overview)- Node.js 18.x or higher
- npm or yarn
- AWS Account (for backend deployment)
- Git
git clone https://github.com/yourusername/codebook-ecommerce.git
cd codebook-ecommercecd codebook
npm installCreate a .env file in the codebook/ directory (see Environment Variables section below).
npm startThe application will open at http://localhost:3000
For full functionality, you'll need to deploy the AWS Lambda backend. See the Backend Documentation for detailed instructions.
Create a .env file in the codebook/ directory:
# API Configuration
REACT_APP_LAMBDA_API_URL=https://your-api-gateway-url.execute-api.region.amazonaws.com
REACT_APP_BASE_URL=http://localhost:3000
# Stripe (Payment Processing)
REACT_APP_STRIPE_PUB_KEY=pk_test_your_stripe_public_key
# Cloudinary (Image Upload)
REACT_APP_CLOUDINARY_CLOUD_NAME=your_cloud_name
REACT_APP_CLOUDINARY_UPLOAD_PRESET=your_upload_preset
REACT_APP_IMAGE_SERVICE=cloudinary
# Demo Accounts (Optional)
REACT_APP_ADMIN_LOGIN=admin@example.com
REACT_APP_ADMIN_PASSWORD=12345678
REACT_APP_GUEST_LOGIN=test@example.com
REACT_APP_GUEST_PASSWORD=12345678For AWS Lambda deployment, see codebook/aws-lambda/README.md for detailed secrets management.
Required Secrets:
JWT_SECRET- Secret key for JWT token signingSTRIPE_SECRET_KEY- Stripe secret keySTRIPE_WEBHOOK_SECRET- Stripe webhook secretBREVO_API_KEY- Brevo email API keyBREVO_SENDER_EMAIL- Sender email addressBREVO_ADMIN_EMAIL- Admin notification emailSHIPPO_API_KEY- Shippo API key for shipping labels
- Stripe: Sign up at stripe.com β Dashboard β Developers β API keys
- Cloudinary: Sign up at cloudinary.com β Dashboard β Settings β Upload presets
- Brevo: Sign up at brevo.com β Settings β API Keys
- Shippo: Sign up at goshippo.com β Settings β API
# Navigate to frontend directory
cd codebook
# Install all dependencies
npm install- Copy
.env.exampleto.env(if available) or create a new.envfile - Fill in all required environment variables (see above)
# Navigate to Lambda directory
cd aws-lambda
# Install Lambda dependencies
npm install
# Configure AWS credentials
export AWS_ACCESS_KEY_ID=your_access_key
export AWS_SECRET_ACCESS_KEY=your_secret_key
export AWS_REGION=eu-north-1
# Set up secrets (see aws-lambda/README.md)
cp .env.secrets.example .env.secrets
# Edit .env.secrets with your actual secretscd aws-lambda
./deploy.shThis will deploy all Lambda functions and return an API Gateway URL. Update your frontend .env with this URL.
cd codebook
npm start- Opens
http://localhost:3000 - Hot reload enabled
- Development tools available
cd codebook
npm run buildCreates an optimized production build in the build/ directory.
cd codebook
npm test-
Connect Repository to Vercel
- Go to vercel.com
- Import your GitHub repository
- Set root directory to
codebook
-
Configure Environment Variables
- Add all
REACT_APP_*variables in Vercel dashboard - Use production URLs for
REACT_APP_BASE_URLandREACT_APP_LAMBDA_API_URL
- Add all
-
Deploy
- Vercel will automatically deploy on push to main branch
- Or manually deploy via Vercel CLI:
vercel deploy
See detailed instructions in codebook/aws-lambda/README.md:
cd codebook/aws-lambda
./deploy.sh-
Frontend Documentation - Complete React app documentation
- Component guide
- Hooks reference
- API services
- State management
- Code examples
-
Backend Documentation - AWS Lambda backend docs
- Deployment guide
- Secrets management
- Cost monitoring
- Troubleshooting
- Mock JSON Server Reference - Archived mock backend
- Vercel Functions Reference - Archived Vercel functions
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β React Application β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Routing β β Context β β React β β
β β Layer ββ β Providers ββ β Query β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β β β β
β ββββββββββββββββββββΌβββββββββββββββββββ β
β β β
β βββββββββΌβββββββββ β
β β Components β β
β β β β
β β - Pages β β
β β - UI Cards β β
β β - Forms β β
β β - Layouts β β
β βββββββββ¬βββββββββ β
β β β
β βββββββββΌβββββββββ β
β β Service Layer β β
β β β β
β β - API Calls β β
β β - Error β β
β β Handling β β
β βββββββββ¬βββββββββ β
β β β
ββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββ
β
HTTPS Requests
β
ββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββ
β AWS API Gateway β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ-
Server State: TanStack React Query
- API data fetching
- Caching with
staleTime: Infinity - Automatic cache invalidation
- Optimistic updates
-
Client State: React Context + useReducer
- Cart state (
CartContext) - Filter state (
FilterContext) - Loading state (
LoadingContext)
- Cart state (
-
Form State: Controlled components
- React state for form inputs
- Validation with custom hooks
- Error handling
GET /products # Get all products
GET /products/:id # Get product by ID
POST /auth/login # User login
POST /auth/register # User registration
# Orders
GET /orders # Get user orders
POST /orders # Create new order
# Reviews
GET /reviews/product/:id # Get product reviews
POST /reviews # Create review
# Tickets
GET /tickets # Get user tickets
POST /tickets # Create ticket
PUT /tickets/:id # Update ticket
# Products
POST /admin/products # Create product
PUT /admin/products/:id # Update product
DELETE /admin/products/:id # Delete product
# Orders
GET /admin/orders # Get all orders
PUT /admin/orders/:id # Update order status
POST /admin/orders/:id/refund # Process refund
# Users
GET /admin/users # Get all users
PUT /admin/users/:id # Update user
DELETE /admin/users/:id # Delete user
# Analytics
GET /admin/analytics/revenue # Revenue analytics
GET /admin/analytics/sales # Sales trends
Full API Documentation: See codebook/aws-lambda/README.md for detailed endpoint documentation.
All UI components are built on ShadCN UI for maximum reusability:
// Example: Using Card component
import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card";
function ProductCard({ product }) {
return (
<Card>
<CardHeader>
<CardTitle>{product.name}</CardTitle>
</CardHeader>
<CardContent>
<p>{product.overview}</p>
</CardContent>
</Card>
);
}Reusable hooks for common functionality:
// useProducts - Fetch and manage products
import { useProducts } from "@/hooks/useProducts";
function ProductsPage() {
const { products, isLoading, error } = useProducts();
// Use products data
}
// useCart - Cart management
import { useCart } from "@/context/CartContext";
function CartButton() {
const { addToCart, cartItems } = useCart();
// Manage cart
}Centralized API calls:
// productService.js
import { apiClient } from "./apiClient";
export const productService = {
getAll: () => apiClient.get("/products"),
getById: (id) => apiClient.get(`/products/${id}`),
create: (data) => apiClient.post("/admin/products", data),
};For detailed component examples, see codebook/README.md section on "Reusing Components".
import { useQuery } from "@tanstack/react-query";
import { productService } from "@/services/productService";
function ProductDetail({ productId }) {
const {
data: product,
isLoading,
error,
} = useQuery({
queryKey: ["product", productId],
queryFn: () => productService.getById(productId),
staleTime: Infinity, // Cache forever until invalidation
});
if (isLoading) return <LoadingState />;
if (error) return <ErrorState error={error} />;
return <ProductCard product={product} />;
}import { useMutation, useQueryClient } from "@tanstack/react-query";
import { productService } from "@/services/productService";
import { toast } from "react-toastify";
function CreateProductForm() {
const queryClient = useQueryClient();
const mutation = useMutation({
mutationFn: productService.create,
onSuccess: () => {
// Invalidate and refetch products
queryClient.invalidateQueries({ queryKey: ["products"] });
toast.success("Product created successfully!");
},
onError: (error) => {
toast.error(error.message);
},
});
const handleSubmit = (data) => {
mutation.mutate(data);
};
return <form onSubmit={handleSubmit}>...</form>;
}// CartContext.js
import { createContext, useContext, useReducer } from "react";
import { cartReducer } from "@/reducers/cartReducers";
const CartContext = createContext();
export function CartProvider({ children }) {
const [cart, dispatch] = useReducer(cartReducer, []);
const addToCart = (product) => {
dispatch({ type: "ADD_TO_CART", payload: product });
};
return (
<CartContext.Provider value={{ cart, addToCart }}>
{children}
</CartContext.Provider>
);
}
// Usage
function ProductCard({ product }) {
const { addToCart } = useContext(CartContext);
return <button onClick={() => addToCart(product)}>Add to Cart</button>;
}// ProtectedRoute.js
import { Navigate } from "react-router-dom";
import { useUser } from "@/hooks/useUser";
function ProtectedRoute({ children, requireAdmin = false }) {
const { user, isLoading } = useUser();
if (isLoading) return <LoadingState />;
if (!user) return <Navigate to="/login" />;
if (requireAdmin && !user.isAdmin) return <Navigate to="/" />;
return children;
}
// Usage in routes
<Route
path="/admin"
element={
<ProtectedRoute requireAdmin>
<AdminDashboard />
</ProtectedRoute>
}
/>;More code examples: See codebook/README.md for comprehensive examples.
Frontend: React, React Router, React Query, TanStack Query, Hooks, Context API, Tailwind CSS, ShadCN UI, Responsive Design, Dark Mode, Component Reusability, State Management, Form Validation, Error Handling, Loading States, Toast Notifications
Backend: AWS Lambda, Serverless, API Gateway, DynamoDB, JWT Authentication, bcrypt, Node.js, AWS SAM, Infrastructure as Code, RESTful API, HTTP API
Services: Stripe, Payment Processing, Cloudinary, Image Upload, Brevo, Email Service, Shippo, Shipping Labels, QR Code Generation
Architecture: Serverless Architecture, Microservices, NoSQL Database, REST API, JWT Tokens, Role-Based Access Control, Caching Strategy, Optimistic Updates, Error Boundaries
DevOps: Vercel Deployment, AWS Deployment, Environment Variables, Secrets Management, Cost Monitoring, CloudWatch, CI/CD
E-Commerce: Shopping Cart, Checkout, Order Management, Product Management, Inventory Management, Stock Tracking, Reviews, Ratings, Support Tickets, Analytics, Dashboard
This is an educational project. Contributions are welcome! Here's how you can contribute:
- Fork the Repository
- Create a Feature Branch:
git checkout -b feature/amazing-feature - Make Your Changes: Follow the existing code style and patterns
- Test Your Changes: Ensure all functionality works correctly
- Commit Your Changes:
git commit -m 'Add amazing feature' - Push to Branch:
git push origin feature/amazing-feature - Open a Pull Request: Describe your changes clearly
- Use functional components with hooks
- Follow React best practices
- Use explicit TypeScript types (even in .js files via JSDoc)
- Maintain consistent naming conventions
- Add comments for complex logic
- Use ShadCN UI components when possible
- Follow the existing project structure
CodeBook E-Commerce is a comprehensive, production-ready e-commerce platform that demonstrates modern web development practices. It showcases:
- Modern React Patterns: Hooks, Context, React Query
- Serverless Architecture: AWS Lambda + API Gateway + DynamoDB
- Third-Party Integrations: Stripe, Cloudinary, Brevo, Shippo
- Production Best Practices: Error handling, caching, optimization
- Educational Value: Well-documented code for learning
- Building scalable React applications
- Serverless backend architecture
- State management with React Query
- Payment processing integration
- Admin dashboard development
- Responsive design patterns
- API design and integration
- AWS services usage
- Explore the Code: Start with
codebook/src/App.jsand follow the routes - Read the Documentation: Check
codebook/README.mdfor detailed guides - Deploy Your Own: Follow the deployment guides to set up your instance
- Extend the Features: Add new functionality and learn by doing
Feel free to use this project repository and extend this project further!
If you have any questions or want to share your work, reach out via GitHub or my portfolio at https://arnob-mahmud.vercel.app/.
Enjoy building and learning! π
Thank you! π



















