FastAPI Shop is your go-to starting point for building a modern, efficient, and highly customizable online shop. This project, powered by FastAPI, SQLAlchemy, and Pydantic, provides a solid foundation for launching or enhancing your venture with a feature-rich online shopping experience.
-
RESTful API: Utilizes FastAPI to deliver a RESTful API for managing products, orders, users, and more.
-
Database Integration: Integrates SQLAlchemy for database operations, supporting various systems like PostgreSQL, MySQL, SQLite, or others.
-
Data Validation: Leverages Pydantic for request and response data validation, ensuring data integrity and security.
-
Authentication and Authorization: Implements user authentication and authorization mechanisms to secure the application.
-
Product Management: Facilitates the management of products, including adding, updating, and deleting.
-
Order Management: Supports order creation, tracking, and management.
-
User Management: Provides user registration, login, and profile management functionalities.
-
Customization: Easily tailor the project to fit your specific eCommerce requirements and branding.
- Python 3.8 or higher
- pip
- Virtualenv (optional but recommended)
-
Clone the repository:
git clone https://github.com/zamaniamin/fastapi-shop.git
-
Navigate to the project directory:
cd fastapi-shop -
Create and activate a virtual environment (recommended):
virtualenv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install project dependencies:
pip install -r requirements.txt
To configure your FastAPI Shop project, create a .env file by copying the .env.template file and filling in the
actual values. Here's an example:
- Copy
.env.templateto.env. - Open
.envin a text editor. - Replace the placeholder values with your actual configuration details.
- Save the file.
-
Start the FastAPI server:
uvicorn apps.main:app --reload
-
Access the API documentation at
http://localhost:8000/docsto explore and interact with the API endpoints using the Swagger UI. -
Add Demo Data:
-
Step 1 (Optional): You can skip this step if you don't want to add your own demo images. The project includes existing demo images located at
apps/demo/media/products/{product_id}. -
Step 2: To prevent conflicts during development, remove your database tables. For development, I recommend using SQLite.
-
Step 3: Run the following command to create demo data, including fake products with images, a fake admin, and a fake user:
python demo.py
This will populate your database with a variety of demo data for testing and development purposes.
-
FastAPI Shop is designed to be highly customizable to suit your eCommerce needs. You can extend and modify the project by:
- Adding new API endpoints to handle additional features.
- Customizing the database models in
models.pyto reflect your product catalog, user profiles, and more. - Enhancing the user interface by integrating a front-end framework of your choice.
For deployment, consider using popular cloud platforms like AWS, Google Cloud, or Heroku. Ensure you set up proper security measures and scalability options.
Contributions to this project are welcome. Feel free to submit bug reports, feature requests, or pull requests.
This project is licensed under the MIT License. See the LICENSE file for details.
For questions or inquiries, please contact Amin Zamani.