=======
A full-stack e-commerce application built with React.js frontend and Node.js/Express backend, featuring user authentication, product management, order processing, and admin dashboard.
- User Authentication: Sign up, sign in, and profile management
- Product Browsing: View products with search and filtering capabilities
- Shopping Cart: Add/remove items and manage cart contents
- Order Management: Place orders and view order history
- Product Details: Detailed product information and images
- Responsive Design: Mobile-friendly interface
- Dashboard: Analytics and overview of sales, orders, and users
- Product Management: Add, edit, and delete products
- Order Management: View and manage all customer orders
- User Management: View and manage user accounts
- Image Upload: Cloudinary integration for product images
- React.js 19 - UI framework
- Vite - Build tool and development server
- React Router DOM - Client-side routing
- Tailwind CSS - Utility-first CSS framework
- Axios - HTTP client for API calls
- React Hot Toast - Toast notifications
- JWT Decode - JWT token handling
- Heroicons & Lucide React - Icon libraries
- Recharts - Data visualization
- Node.js - Runtime environment
- Express.js - Web framework
- MongoDB - NoSQL database
- Mongoose - MongoDB object modeling
- JWT - Authentication tokens
- Bcryptjs - Password hashing
- Multer - File upload handling
- Cloudinary - Cloud image storage
- CORS - Cross-origin resource sharing
βββ frontend/ # React frontend application
β βββ src/
β β βββ components/ # Reusable UI components
β β βββ pages/ # Page components
β β βββ context/ # React context providers
β β βββ utils/ # Utility functions
β βββ public/ # Static assets
β βββ package.json
βββ server/ # Node.js backend application
β βββ controllers/ # Route controllers
β βββ models/ # Database models
β βββ routes/ # API routes
β βββ middleware/ # Custom middleware
β βββ db/ # Database configuration
β βββ package.json
βββ README.md
- Node.js (v16 or higher)
- MongoDB (local or cloud instance)
- Cloudinary account (for image uploads)
-
Clone the repository
git clone https://github.com/Bharath18sv/SnapCart.git cd snapcart -
Install Frontend Dependencies
cd frontend npm install -
Install Backend Dependencies
cd ../server npm install -
Environment Setup
Create
.envfile in the server directory:PORT=3000 MONGODB_URI=your_mongodb_connection_string JWT_SECRET=your_jwt_secret_key CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name CLOUDINARY_API_KEY=your_cloudinary_api_key CLOUDINARY_API_SECRET=your_cloudinary_api_secret
Create
.envfile in the frontend directory:VITE_API_URL=http://localhost:3000/api
-
Start the Backend Server
cd server npm startThe server will run on
http://localhost:3000 -
Start the Frontend Development Server
cd frontend npm run devThe frontend will run on
http://localhost:5173
POST /api/auth/signup- User registrationPOST /api/auth/signin- User loginGET /api/auth/profile- Get user profile
GET /api/products- Get all productsGET /api/products/:id- Get product by IDPOST /api/products- Create new product (Admin)PUT /api/products/:id- Update product (Admin)DELETE /api/products/:id- Delete product (Admin)
GET /api/orders- Get user ordersGET /api/orders/admin- Get all orders (Admin)POST /api/orders- Create new orderPUT /api/orders/:id- Update order status (Admin)
The application uses JWT (JSON Web Tokens) for authentication and role-based access control:
- User Role: Can browse products, manage cart, place orders
- Admin Role: Can manage products, orders, and users
- Layout: Main layout wrapper with navigation
- Navbar: Navigation bar with user menu
- ProductList: Product grid display
- Cart: Shopping cart management
- AdminDashboard: Admin analytics dashboard
- ProtectedRoute: Route protection based on user roles
- User: User account information
- Product: Product details and inventory
- Order: Order information and status
cd frontend
npm run buildThe built files will be in the dist folder, ready for deployment to platforms like Vercel, Netlify, or any static hosting service.
The backend can be deployed to platforms like:
- Heroku
- Railway
- DigitalOcean
- AWS
Make sure to set up environment variables on your deployment platform.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the ISC License.
- Bharath S V - Initial work
- React.js community
- Tailwind CSS for the beautiful UI framework
- MongoDB for the database solution
- Cloudinary for image storage services