{"id":15175740,"url":"https://github.com/debrajhyper/e-commerce","last_synced_at":"2026-02-06T05:31:12.113Z","repository":{"id":254615866,"uuid":"846869361","full_name":"debrajhyper/e-commerce","owner":"debrajhyper","description":"This is a comprehensive e-commerce full-stack application built using Next.js for the frontend and Node.js with Express.js for the backend. It provides functionality for user authentication, seller product management, and buyer shopping experience.","archived":false,"fork":false,"pushed_at":"2024-08-24T18:28:47.000Z","size":4795,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-05T04:03:09.730Z","etag":null,"topics":["bcryptjs","cors","expressjs","jwt-authentication","nextjs14","nodejs","postgresql","reacthookform","reactjs","shadcn-ui","tailwindcss","typescript","zod","zustand"],"latest_commit_sha":null,"homepage":"https://ecommerce-work.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/debrajhyper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-24T07:14:44.000Z","updated_at":"2024-08-24T18:28:51.000Z","dependencies_parsed_at":"2024-08-24T19:57:17.415Z","dependency_job_id":null,"html_url":"https://github.com/debrajhyper/e-commerce","commit_stats":null,"previous_names":["debrajhyper/e-commerce"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/debrajhyper/e-commerce","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debrajhyper%2Fe-commerce","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debrajhyper%2Fe-commerce/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debrajhyper%2Fe-commerce/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debrajhyper%2Fe-commerce/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/debrajhyper","download_url":"https://codeload.github.com/debrajhyper/e-commerce/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debrajhyper%2Fe-commerce/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266194221,"owners_count":23890956,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bcryptjs","cors","expressjs","jwt-authentication","nextjs14","nodejs","postgresql","reacthookform","reactjs","shadcn-ui","tailwindcss","typescript","zod","zustand"],"created_at":"2024-09-27T12:41:22.866Z","updated_at":"2026-02-06T05:31:12.104Z","avatar_url":"https://github.com/debrajhyper.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🛍️ E-commerce Full Stack Application\n\nThis is a comprehensive e-commerce full-stack application built using Next.js for the frontend and Node.js with Express.js for the backend. It provides functionality for user authentication, seller product management, and buyer shopping experience.\n\n## 😍 UI\n\n\n\n\u003cp align=\"center\"\u003e\n  \u003cp\u003eHomepage \u0026 404 error page\u003c/p\u003e\n  \u003cp\u003e\n  \u003cimg src=\"./thumbnail/image3.png\" width=\"410\"/\u003e\n  \u003cimg src=\"./thumbnail/image17.png\"width=\"410\"/\u003e\n  \u003c/p\u003e\n  \u003cp\u003eLogin \u0026 Signup Page\u003c/p\u003e\n  \u003cp\u003e\n  \u003cimg src=\"./thumbnail/image4.png\" width=\"410\"/\u003e\n  \u003cimg src=\"./thumbnail/image5.png\" width=\"410\"/\u003e\n  \u003c/p\u003e\n  \u003cp\u003eLogin \u0026 Signup form validation\u003c/p\u003e\n  \u003cp\u003e\n  \u003cimg src=\"./thumbnail/image7.png\" width=\"410\"/\u003e\n  \u003cimg src=\"./thumbnail/image6.png\" width=\"410\"/\u003e\n  \u003c/p\u003e\n  \u003cp\u003eBuyer \u0026 Seller dashboard Page\u003c/p\u003e\n  \u003cp\u003e\n  \u003cimg src=\"./thumbnail/image13.png\"width=\"410\"/\u003e\n  \u003cimg src=\"./thumbnail/image8.png\" width=\"410\"/\u003e\n  \u003c/p\u003e\n  \u003cp\u003eAdvance search functionality for product name \u0026 category\u003c/p\u003e\n  \u003cp\u003e\n  \u003cimg src=\"./thumbnail/image14.png\"width=\"410\"/\u003e\n  \u003cimg src=\"./thumbnail/image15.png\"width=\"410\"/\u003e\n  \u003c/p\u003e\n  \u003cp\u003eFallback loading UI\u003c/p\u003e\n  \u003cp\u003e\n  \u003cimg src=\"./thumbnail/image1.png\" width=\"410\"/\u003e\n  \u003cimg src=\"./thumbnail/image2.png\" width=\"410\"/\u003e\n  \u003c/p\u003e\n  \u003cp\u003eUnauthorize access page for protected routes \u0026 Buyer cart page\u003c/p\u003e\n  \u003cp\u003e\n  \u003cimg src=\"./thumbnail/image18.png\"width=\"410\"/\u003e\n  \u003cimg src=\"./thumbnail/image16.png\" width=\"410\"/\u003e\n  \u003c/p\u003e\n  \u003cp\u003eSeller Add \u0026 Edit product page\u003c/p\u003e\n  \u003cp\u003e\n  \u003cimg src=\"./thumbnail/image9.png\" width=\"410\"/\u003e\n  \u003cimg src=\"./thumbnail/image11.png\"width=\"410\"/\u003e\n  \u003c/p\u003e\n  \u003cp\u003eAdd \u0026 Edit product form fields with custom validation\u003c/p\u003e\n  \u003cp\u003e\n  \u003cimg src=\"./thumbnail/image10.png\"width=\"410\"/\u003e\n  \u003cimg src=\"./thumbnail/image12.png\"width=\"410\"/\u003e\n  \u003c/p\u003e\n\u003c/p\u003e\n\n## 🕹️ Tech Stack\n\n### Frontend\n- Next.js 14.2.6\n- React 18\n- TypeScript\n- Tailwind CSS\n- Additional libraries:\n  - @hookform/resolvers\n  - @radix-ui (for UI components)\n  - axios (for API requests)\n  - react-hook-form (for form handling)\n  - zod (for schema validation)\n  - zustand (for state management)\n\n### Backend\n- Node.js\n- Express.js\n- PostgreSQL (pg driver)\n- Additional libraries:\n  - bcryptjs (for password hashing)\n  - jsonwebtoken (for JWT authentication)\n  - cors (for handling Cross-Origin Resource Sharing)\n  - dotenv (for environment variable management)\n\n## 🎉 Features\n\n### User Authentication \u0026 Authorization\n- Role based dynamic routes based on user login.\n- JSON Web Tokens (JWT) used for maintaining user sessions.\n- Tokens securely stored on the client-side for persistent authentication.\n- Distinct user roles (seller and buyer) with different permissions and access levels.\n- Users can create accounts as either sellers or buyers.\n- Custom form validation enforced for enhanced security.\n- Passwords hashed using bcrypt before storage in the database.\n- Handled Unauthorized access for all roles.\n- Seamless one click logout feature.\n\n### Seller Functionality\n- Sellers can easily add new products with detailed information:\n  - Product name\n  - Category selection from predefined options\n  - Rich text description support\n  - Price setting with discount\n- Edit existing product details and update information in real-time.\n- Remove products from the marketplace with safeguards against accidental deletion.\n- Have access for his own added products only.\n\n### Buyer Functionality\n- Search functionality allowing users to find products by name or category.\n- Implemented advance debounced search functionality for better UI rendering. \n- Sort results automatically by acceding order on every request.\n- Buyer can have the flexibility for add to card with quantity directly from product card.\n- Remove items or adjust quantities directly from the cart table.\n- Persistent cart that saves items for logged-in users across sessions.\n- Added cart notification dot with cart count for real time updates.\n\n### Responsive Design\n\n- Fully responsive interface adaptable to various screen sizes (desktop, tablet, mobile).\n- Consistent user experience across different devices.\n\n### Security Features\n\n- HTTPS encryption for all data transmissions.\n- CSRF protection for form submissions.\n- Input validation and sanitization to prevent SQL injection and XSS attacks.\n\n## 🪄 Best Practices\n\n- [✔️] **Input Validation**: All user inputs are validated and sanitized using Zod before being processed or stored in the database.\n- [✔️] **Routing**: Next.js file-based routing system is used effectively, with dynamic routes implemented where necessary.\n- [✔️] **Responsiveness**: The application is designed to be responsive across various devices and screen sizes using Tailwind CSS.\n- [✔️] **Error Handling**: Proper error handling is implemented for various scenarios, with clear and meaningful error messages returned to the client.\n- [✔️] **Code Quality**: The codebase maintains high standards of readability and maintainability, with appropriate comments explaining complex logic.\n- [✔️] **Security**: Best practices for security are followed, including secure authentication with JWT and bcrypt for password hashing.\n- [✔️] **State Management**: Zustand is used for efficient and scalable state management on the frontend.\n- [✔️] **Form Handling**: react-hook-form is utilized for efficient and performant form handling.\n- [✔️] **API Requests**: Axios is used for making HTTP requests, providing a consistent interface for both browser and node.js environments.\n- [✔️] **UI Components**: Shadcn UI is used for accessible and customizable UI components.\n\n## 📦 Setup Instructions\n\n### Frontend Setup\n\n1. Clone and navigate to the client directory:\n    ```bash\n    git clone https://github.com/debrajhyper/e-commerce.git\n    cd e-commerce/client\n    ```\n\n2. Install dependencies:\n    ```bash\n    npm install\n    ```\n\n3. Create a .env file in the root of the client directory and add:\n    ```bash\n    API_BASE_URL=http://localhost:5000/api // Backend server URL\n    ```\n\n4. Run the development server:\n    ```bash\n    npm run dev\n    ```\n\n5. Open [http://localhost:3000](http://localhost:3000) in your browser to see the application.\n\n### Backend Setup\n\n1. Navigate to the server directory:\n   ```bash\n   cd e-commerce/server\n   ```\n\n2. Install dependencies:\n   ```bash\n   npm install\n   ```\n\n3. Create a `.env` file in the root of the server directory and add:\n   ```bash\n    DB_USER=DATABASE_USER\n    DB_HOST=DATABASE_HOST\n    DB_NAME=DATABASE_NAME\n    DB_PASSWORD=DATABASE_PASSWORD\n    DB_PORT=DATABASE_PORT\n    JWT_SECRET=JWT_SECRET\n    AUTH_ROLE_BUYER=buyer\n    AUTH_ROLE_SELLER=seller\n    PORT=5000\n   ```\n\n4. Set up your PostgreSQL database and update the connection string in `.env`.\n\n5. Run the server:\n   ```bash\n   node serve.js\n   ```\n\n## 📃 API Documentation\n\n### Authentication\n\n#### POST /api/auth/signup\nCreate a new user account.\n\nRequest body:\n```json\n{\n  \"email\": \"string\",\n  \"password\": \"string\",\n  \"role\": \"seller\" | \"buyer\"\n}\n```\n\n#### POST /api/auth/login\nLog in to an existing account.\n\nRequest body:\n```json\n{\n  \"email\": \"string\",\n  \"password\": \"string\"\n}\n```\n\nResponse:\n```json\n{\n  \"token\": \"jwt_token\",\n}\n```\n\n### Products\n\n#### GET /api/products\nGet all products.\n\nResponse:\n```json\n[\n  {\n    \"id\": \"string\",\n    \"name\": \"string\",\n    \"category\": \"string\",\n    \"description\": \"string\",\n    \"price\": number,\n    \"discount\": number,\n    \"sellerId\": \"string\"\n  }\n]\n```\n\n#### GET /api/products/:id\nGet a specific product by ID.\n\nResponse:\n```json\n{\n    \"id\": \"string\",\n    \"name\": \"string\",\n    \"category\": \"string\",\n    \"description\": \"string\",\n    \"price\": \"string\",\n    \"discount\": \"string\",\n    \"sellerId\": \"string\"\n}\n```\n\n#### POST /api/products\nCreate a new product (seller only).\n\nRequest body:\n```json\n{\n    \"name\": \"string\",\n    \"category\": \"string\",\n    \"description\": \"string\",\n    \"price\": \"string\",\n    \"discount\": \"string\"\n}\n```\n\n#### PUT /api/products/:id\nUpdate an existing product (seller only).\n\nRequest body:\n```json\n{\n    \"id\": \"string\",\n    \"name\": \"string\",\n    \"category\": \"string\",\n    \"description\": \"string\",\n    \"price\": \"string\",\n    \"discount\": \"string\"\n}\n```\n\n#### DELETE /api/products/:id\nDelete a product (seller only).\n\n### Cart\n\n#### GET /api/cart\nGet the current user's cart.\n\nResponse:\n```json\n[\n    {\n        \"id\": \"string\",\n        \"name\": \"string\",\n        \"category\": \"string\",\n        \"description\": \"string\",\n        \"price\": \"string\",\n        \"discount\": \"string\",\n        \"quantity\": number,\n        \"seller_id\": number\n    }\n]\n```\n\n#### POST /api/cart\nAdd a product to the cart.\n\nRequest body:\n```json\n{\n  \"productId\": \"string\",\n  \"quantity\": number\n}\n```\n\n#### DELETE /api/cart/:productId\nRemove a product from the cart.\n\n\n## 🗃️ Project Structure\n\n### Frontend (Next.js)\n```\nclient/\n├── public/\n├── src/\n│   ├── app/\n│   |   ├── auth/\n│   |   |   ├── login/\n│   |   |   |   └── page.tsx\n│   |   |   └── signup/\n│   |   |       └── page.tsx\n│   |   ├── buyer/\n│   |   |   ├── cart/\n│   |   |   |   └── page.tsx\n│   |   |   └── dashboard/\n│   |   |       └── page.tsx\n│   |   ├── seller/\n│   |   |   ├── add-product/\n│   |   |   |   └── page.tsx\n│   |   |   ├── dashboard/\n│   |   |   |   └── page.tsx\n│   |   |   └── edit-product/\n│   |   |       └── page.tsx\n│   |   ├── unauthorize/\n│   |   ├── layout.tsx\n│   |   ├── not-found.tsx\n│   |   └── page.tsx\n│   ├── components/\n│   |   ├── ui/\n│   |   ├── DashboardTitle.tsx\n│   |   ├── ErrorAlert.tsx\n│   |   ├── Footer.tsx\n│   |   ├── Header.tsx\n│   |   ├── ProductCard.tsx\n│   |   ├── ProductCardLoading.tsx\n│   |   ├── ProductCount.tsx\n│   |   ├── ProductForm.tsx\n│   |   └── SearchBar.tsx\n│   ├── constants/\n│   ├── helpers/\n│   ├── hooks/\n│   ├── lib/\n│   ├── public/\n│   ├── store/\n│   ├── styles/\n│   └── utils/\n├── .eslintrc.json\n├── next.config.js\n├── package.json\n├── postcss.config.js\n├── tailwind.config.js\n└── tsconfig.json\n```\n\n### Backend (Node.js)\n```\nserver/\n├── config/\n│   └── database.js\n├── controllers/\n│   ├── authController.js\n│   ├── cartController.js\n│   └── productController.js\n├── middleware/\n│   └── auth.js\n├── models/\n│   ├── Cart.js\n│   ├── Product.js\n│   └── User.js\n├── routes/\n│   ├── auth.js\n│   ├── cart.js\n│   └── products.js\n├── .env\n├── package.json\n└── server.js\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdebrajhyper%2Fe-commerce","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdebrajhyper%2Fe-commerce","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdebrajhyper%2Fe-commerce/lists"}