The Shoplit API is a backend service for an e-commerce platform. It allows users to interact with product data, categories, and subcategories via RESTful endpoints. The API is built using Django and Django REST Framework (DRF).
Deployed Version: https://shoplit.onrender.com/
- User Registration: Create user accounts.
- User Authentication: Login/logout functionality with token-based authentication.
- Password Reset: Reset forgotten passwords via email.
- User Profiles: View and update user information.
- Product Listings: Fetch a list of all available products.
- Product Details: Retrieve detailed information for a specific product.
- Category & Subcategory Management: Filter products by category or subcategory.
- Product Search: Search for products by name or description.
- Product pagination and caching: For faster performance
- Add to Cart: Add products to a shopping cart.
- View Cart: Retrieve items in the user’s cart.
- Update Cart: Adjust quantities of products in the cart.
- Remove from Cart: Delete items from the cart.
- Place Orders: Checkout and place orders for products in the cart.
- Order History: View all orders placed by a user.
- Order Details: Fetch detailed information about a specific order.
- Payment Gateway: Integration with paystack.
- Order Payment Status: Update and track payment status of orders.
- Add to Wishlist: Save products for later purchase.
- View Wishlist: Fetch the user’s wishlist items.
- Remove from Wishlist: Delete items from the wishlist.
- Product Reviews: Allow users to leave reviews and ratings for products.
- Review Moderation: Approve or reject reviews for public display.
- Review Display: Fetch all reviews for a specific product.
- Order Status Updates: Notify users about order status changes via in app and SMS.
- Promotional Notifications: Send updates about sales, discounts, or new arrivals.
- Order Updates: Notify users via SMS about their order status (e.g., confirmed, shipped, delivered).
- Promotions: Send promotional offers and updates directly to users' phones.
To run the API locally, ensure you have the following installed:
- Python 3.9+
- Django
- Django REST Framework
- MySQL (or any database supported by Django)
- Use the requirements.txt file
-
Clone the repository:
git clone https://github.com/Andrew-oduola/shoplit.git cd shoplit -
Create and activate a virtual environment:
python -m venv env source env/bin/activate # On Windows, use env\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Configure environment variables:
- Create a
.envfile in the project root. - Add the following variables:
SECRET_KEY=your_secret_key DEBUG=True ALLOWED_HOSTS=localhost, 127.0.0.1 DATABASE_URL=your_database_url
- Create a
-
Run database migrations:
python manage.py migrate
-
Start the development server:
python manage.py runserver
GET /api/products/
Response:
[
{
"id": "4e33465d-9845-4129-af1e-5d647fbf3b02",
"name": "Product Name",
"description": "Product description",
"price": 29.99,
"category": "Category Name",
"subcategory": "Subcategory Name"
},
...
]GET /api/products/<id>/
Response:
{
"id": "4e33465d-9845-4129-af1e-5d647fbf3b02",
"name": "Product Name",
"description": "Product description",
"price": 29.99,
"category": "Category Name",
"subcategory": "Subcategory Name"
}POST /api/products/
Request:
{
"name": "New Product",
"description": "New product description",
"price": 19.99,
"category": "Category Name",
"subcategory": "Subcategory Name"
}Response:
{
"id": "4e33465d-9845-4129-af1e-5d647fbf3b02",
"name": "New Product",
"description": "New product description",
"price": 19.99,
"category": "Category Name",
"subcategory": "Subcategory Name"
}PUT /api/products/<id>/
Request:
{
"name": "Updated Product",
"description": "Updated product description",
"price": 24.99
}Response:
{
"id": "4e33465d-9845-4129-af1e-5d647fbf3b02",
"name": "Updated Product",
"description": "Updated product description",
"price": 24.99
}DELETE /api/products/<id>/
Response:
{
"message": "Product deleted successfully."
}
### Categories
#### List All Categories
**GET** `/api/categories/`
Response:
```json
[
{
"id": "4e33465d-9845-4129-af1e-5d647fbf3b02",
"name": "Category Name",
"description": "Category description"
},
...
]POST /api/categories/
Request:
{
"name": "New Category",
"description": "New category description"
}Response:
{
"id": "4e33465d-9845-4129-af1e-5d647fbf3b02",
"name": "New Category",
"description": "New category description"
}GET /api/subcategories/
Response:
[
{
"id": "4e33465d-9845-4129-af1e-5d647fbf3b02",
"name": "Subcategory Name",
"category": "Category Name"
},
...
]To deploy on Heroku:
-
Log in to Heroku:
heroku login
-
Create a Heroku app:
heroku create shoplit
-
Add Heroku Postgres:
heroku addons:create heroku-postgresql:hobby-dev
-
Push to Heroku:
git push heroku main
-
Run migrations on Heroku:
heroku run python manage.py migrate
-
Open the app:
heroku open
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a feature branch:
git checkout -b feature-name. - Commit your changes:
git commit -m 'Add new feature'. - Push to your branch:
git push origin feature-name. - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.