FreshlyNow is a full-stack e-commerce web application that allows users to browse products, add them to the cart, and make purchases. The application includes both a frontend built with React and a backend built with Node.js, Express, and MongoDB.
- Features
- Technologies Used
- Project Structure
- Installation
- Running the Application
- API Endpoints
- Contributing
- License
- User authentication (signup, login)
- Product browsing and search
- Shopping cart management
- Order placement and history
- Admin panel for product and order management
- Responsive design
- React
- React Router
- Axios
- JWT Decode
- CSS Modules
- Node.js
- Express
- MongoDB
- Mongoose
- JWT (JSON Web Tokens)
- Bcrypt
.gitignore
Backend/
.env
app.js
controllers/
adminController.js
authController.js
cartController.js
orderController.js
paymentController.js
productController.js
userController.js
middlewares/
admin.js
auth.js
models/
cart.js
order.js
product.js
user.js
package.json
public/
css/
images/
js/
views/
routes/
admin.js
auth.js
cart.js
order.js
payment.js
user.js
server.js
Frontend/
.gitignore
build/
package.json
public/
src/
api.js
App.js
App.test.js
components/
context/
pages/
services/
index.js
index.css
setupTests.js
README.md
- Node.js and npm installed on your machine
- MongoDB instance running
- Navigate to the
Backend
directory:
cd Backend
- Install the dependencies:
npm install
- Create a
.env
file in theBackend
directory and add your environment variables:
DATABASE=mongodb+srv://<username>:<password>@cluster0.mongodb.net/<dbname>?retryWrites=true&w=majority JWT_SECRET=your_jwt_secret
Replace <username>
, <password>
, and <dbname>
with your actual database credentials.
- Start the backend server:
npm start
- Navigate to the
Frontend
directory:
cd Frontend
- Install the dependencies:
npm install
- Start the frontend development server:
npm start
- Ensure that both the backend and frontend servers are running.
- Open your browser and navigate to
http://localhost:3000
to view the application.
POST /api/auth/signup
- Register a new userPOST /api/auth/login
- Login a user
GET /api/products
- Get all productsGET /api/products/:id
- Get a product by IDPOST /api/products
- Create a new product (Admin only)PUT /api/products/:id
- Update a product (Admin only)DELETE /api/products/:id
- Delete a product (Admin only)
POST /api/cart
- Add a product to the cartGET /api/cart/:userId
- Get the cart for a userPUT /api/cart
- Update the cartDELETE /api/cart
- Remove a product from the cart
POST /api/order
- Create a new orderGET /api/order
- Get all orders (Admin only)PATCH /api/order/:orderId/status
- Update order status (Admin only)
GET /api/users/profile
- Get user profilePUT /api/users/profile
- Update user profilePUT /api/users/password
- Update user passwordGET /api/users/orders
- Get user's order history
Contributions are welcome! Please fork the repository and create a pull request with your changes.
This project is licensed under the MIT License. See the LICENSE file for details.