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
Note
Make sure you have the following installed:
- Node.js (v18 or higher)
- npm (v9 or higher)
- MongoDB (v7 or higher)
- Clone the repository
git clone https://github.com/iemafzalhassan/EasyShop.git
cd EasyShop
- Install dependencies
npm install
- Set up environment variables
cp .env.example .env.local
Important
Create a .env.local
file in the root directory with the following configuration:
# Database Configuration
MONGODB_URI=mongodb://localhost:27017/easyshop
# Next.js Configuration
NEXTAUTH_URL=http://localhost:3000
NEXT_PUBLIC_API_URL=http://localhost:3000/api
# Authentication
JWT_SECRET=your-secure-jwt-secret-key
Note: Replace your-secure-jwt-secret-key
with a secure secret key for JWT token generation.
You can generate one using JWT Builder Tool or any other secure JWT generator.
Follow these commands in sequence:
- First, run the database migrations to set up your database with initial data:
npm run migrate
- For development:
# Start the development server with hot reload
npm run dev
- For production:
# Build the application
npm run build
# Start the production server
npm start
Note
- Development server runs on: http://localhost:3000
- The migrate command only needs to be run once when setting up the project
- Always run
npm run build
beforenpm start
in production
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 - @Md. Afzal hassan Ehsani
- Project Link: https://github.com/iemafzalhassan/easyshop
Made with β€οΈ by Md. Afzal Hassan Ehsani