EasyShop is a modern, full-stack e-commerce platform built with Next.js 14, TypeScript, and MongoDB. It features a beautiful UI with Tailwind CSS, secure authentication, real-time cart updates, and a seamless shopping experience.
- π¨ Modern and responsive UI with dark mode support
- π Secure JWT-based authentication
- π Real-time cart management with Redux
- π± Mobile-first design approach
- π Advanced product search and filtering
- π³ Secure checkout process
- π¦ Multiple product categories
- π€ User profiles and order history
- π Dark/Light theme support
EasyShop follows a three-tier architecture pattern:
- Next.js React Components
- Redux for State Management
- Tailwind CSS for Styling
- Client-side Routing
- Responsive UI Components
- Next.js API Routes
- Business Logic
- Authentication & Authorization
- Request Validation
- Error Handling
- Data Processing
- MongoDB Database
- Mongoose ODM
- Data Models
- CRUD Operations
- Data Validation
flowchart TD
%% Presentation Tier
subgraph PT[Presentation Tier]
direction TB
UI[React Components]
STORE[Redux Store]
CLIENT[API Clients]
UI -->|User Actions| STORE
STORE -->|State Updates| CLIENT
end
%% Application Tier
subgraph AT[Application Tier]
direction TB
API[Next.js API Routes]
BL[Business Logic]
AUTH[Auth Middleware]
CLIENT -->|HTTP Requests| API
API -->|Process| BL
BL -->|Validate| AUTH
end
%% Data Tier
subgraph DT[Data Tier]
direction TB
ODM[Mongoose ODM]
DB[(MongoDB)]
AUTH -->|Query| ODM
ODM -->|CRUD| DB
end
%% Styling
style PT fill:#e1f5fe,stroke:#01579b
style AT fill:#e3f2fd,stroke:#0277bd
style DT fill:#f3e5f5,stroke:#4a148c
style DB fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
- Separation of Concerns: Each tier has its specific responsibilities
- Scalability: Independent scaling of each tier
- Maintainability: Modular code organization
- Security: API routes handle authentication and data validation
- Performance: Server-side rendering and static generation
- Real-time Updates: Redux for state management
- User interacts with React components
- Actions are dispatched to Redux store
- API clients make requests to Next.js API routes
- API routes process requests through middleware
- Business logic handles data operations
- Mongoose ODM interacts with MongoDB
- Response flows back through the tiers
This guide will help you run EasyShop using Docker containers. No local Node.js or MongoDB installation required!
- Install Docker on your machine
- Basic understanding of terminal/command line
- Create a file named
.env.local
in the root directory with the following content:
# Database Configuration
MONGODB_URI=mongodb://easyshop-mongodb:27017/easyshop
# NextAuth Configuration
NEXTAUTH_URL=http://localhost:3000 # Replace with your EC2 instance's public IP or put localhost:3000
NEXT_PUBLIC_API_URL=http://localhost:3000/api # Replace with your EC2 instance's public IP or put localhost:3000/api
NEXTAUTH_SECRET=your-nextauth-secret-key # Generate this using the command below
# JWT Configuration
JWT_SECRET=your-jwt-secret-key # Generate this using the command below
Important
When deploying to EC2, make sure to replace your-ec2-ip
with your actual EC2 instance's public IP address.
To generate secure secret keys, use these commands in your terminal:
# For NEXTAUTH_SECRET
openssl rand -base64 32
# For JWT_SECRET
openssl rand -hex 32
You have two options to run the application:
This is the easiest way to run the application. All services will be started in the correct order with proper dependencies.
# Start all services
docker compose up -d
# View logs
docker compose logs -f
# Stop all services
docker compose down
If you prefer more control, you can run each service manually:
- Create a Docker network:
docker network create easyshop-network
- Start MongoDB:
docker run -d \
--name easyshop-mongodb \
--network easyshop-network \
-p 27017:27017 \
-v mongodb_data:/data/db \
mongo:latest
- Build the main application:
docker build -t easyshop .
- Build and run data migration:
# Build migration image
docker build -t easyshop-migration -f scripts/Dockerfile.migration .
# Run migration
docker run --rm \
--network easyshop-network \
--env-file .env.local \
easyshop-migration
- Start the EasyShop application:
docker run -d \
--name easyshop \
--network easyshop-network \
-p 3000:3000 \
--env-file .env.local \
easyshop:latest
- Open your web browser
- Visit http://localhost:3000
- You should see the EasyShop homepage!
# View running containers
docker ps
# View container logs
docker logs easyshop
docker logs easyshop-mongodb
# Stop containers
docker stop easyshop easyshop-mongodb
# Remove containers
docker rm easyshop easyshop-mongodb
# Remove network
docker network rm easyshop-network
-
If you can't connect to MongoDB:
- Make sure the MongoDB container is running:
docker ps
- Check MongoDB logs:
docker logs easyshop-mongodb
- Verify network connection:
docker network inspect easyshop-network
- Make sure the MongoDB container is running:
-
If the application isn't accessible:
- Check if the container is running:
docker ps
- View application logs:
docker logs easyshop
- Make sure port 3000 isn't being used by another application
- Check if the container is running:
-
If migration fails:
- Check if MongoDB is running and accessible
- View migration logs when running the migration command
- Verify your .env.local file has the correct MongoDB URI
For any other issues, please create a GitHub issue with the error details.
Note
Coming soon: Unit tests and E2E tests with Jest and Cypress
- Dynamic Server Usage Warnings
Error: Dynamic server usage: Page couldn't be rendered statically
Solution: This is expected behavior for dynamic routes and API endpoints. These warnings appear during build but won't affect the application's functionality.
- MongoDB Connection Issues
Error: MongoDB connection failed
Solution:
- Ensure MongoDB is running locally
- Check if your MongoDB connection string is correct in
.env.local
- Try connecting to MongoDB using MongoDB Compass with the same connection string
- Clear
.next
folder if you encounter strange build issues:rm -rf .next
- Run
npm install
after pulling new changes - Make sure all environment variables are properly set
- Use Node.js version 18 or higher
easyshop/
βββ src/
β βββ app/ # Next.js App Router pages
β βββ components/ # Reusable React components
β βββ lib/ # Utilities and configurations
β β βββ auth/ # Authentication logic
β β βββ db/ # Database configuration
β β βββ features/ # Redux slices
β βββ types/ # TypeScript type definitions
β βββ styles/ # Global styles and Tailwind config
βββ public/ # Static assets
βββ scripts/ # Database migration scripts
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a new branch:
git checkout -b feature/amazing-feature
- Make your changes
- Run tests:
npm test
(coming soon) - Commit your changes:
git commit -m 'Add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
Tip
Check our Contributing Guidelines for more details
This project is licensed under the MIT License - see the LICENSE file for details.
For questions or feedback, please open an issue or contact the maintainers:
- Maintainer - @zehan12
- Project Link: https://github.com/zehan12/easyshop-ecommerce
Made with β€οΈ by Zehan Khan
EasyShop is deployed using a GitOps approach with the following components:
- Jenkins Pipeline: Handles CI/CD, infrastructure deployment, and ArgoCD setup
- Terraform: Manages AWS infrastructure (VPC, EKS, IAM)
- ArgoCD: Manages application deployment using GitOps
- Kubernetes: Runs the application and supporting services
- Monitoring: Prometheus and Grafana for observability
- Jenkins pipeline is triggered by code changes
- Docker images are built and pushed to Docker Hub
- Terraform deploys or updates AWS infrastructure
- ArgoCD is installed on the EKS cluster
- ArgoCD applications are created to deploy EasyShop and monitoring
- ArgoCD syncs the applications from the Git repository
- Jenkinsfile: Main CI/CD pipeline definition
- terraform/: Infrastructure as Code for AWS resources
- kubernetes/: Kubernetes manifests for application deployment
- kubernetes/argocd/: ArgoCD application definitions
- scripts/: Utility scripts for deployment and management
- ArgoCD installation is managed exclusively by the Jenkins pipeline
- Infrastructure is managed by Terraform
- Application deployment is managed by ArgoCD
- Secrets should be managed using AWS Secrets Manager or Kubernetes secrets
For local development, you can use:
# Start a local Kubernetes cluster
kind create cluster --name easyshop
# Deploy the application locally
kubectl apply -f kubernetes/