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.
EasyShop follows a three-tier architecture pattern:
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
[!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: ```bash
npm run build
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` before `npm start` in production
## ๐งช Testing
> [!NOTE]
> Coming soon: Unit tests and E2E tests with Jest and Cypress
## ๐ง Troubleshooting
### Build Errors
1. **Dynamic Server Usage Warnings**
```bash
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.
Error: MongoDB connection failed
Solution:
.env.local
.next
folder if you encounter strange build issues: rm -rf .next
npm install
after pulling new changeseasyshop/
โโโ 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:
git checkout -b feature/amazing-feature
npm test
(coming soon)git commit -m 'Add amazing feature'
git push origin feature/amazing-feature
[!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:
Made with โค๏ธ by Md. Afzal Hassan Ehsani