This is an ecommerce project that provides a backend API for managing users, addresses, products, and orders. It is built using FastAPI, SQLAlchemy, and Alembic.
- Python 3.9 or higher
- PostgreSQL database (or any other supported by SQLAlchemy)
-
Clone the repository:
git clone https://github.com/nfonjeannoel/ecommerce-project.git cd ecommerce-project
-
Create a virtual environment and activate it:
python3 -m venv venv source venv/bin/activate
-
Install the dependencies:
pip install -r requirements.txt
-
Set up the database:
-
Create a PostgreSQL database.
-
Configure the database connection URL in the
.env
file:DATABASE_URL=postgresql://user:password@localhost:5432/database_name
-
Apply the initial database migration:
alembic upgrade head
-
-
Start the server:
uvicorn main:app --reload
The API will be available at http://localhost:8000.
app/
: Contains the main FastAPI application code.alembic/
: Contains the Alembic migration scripts.models.py
: Defines the database models using SQLAlchemy ORM.schemas.py
: Defines the Pydantic schemas for request/response validation.database.py
: Provides the database connection and session management.main.py
: Entrypoint for the FastAPI application.
This project uses Alembic for database migration management. The migration scripts can be found in the alembic/versions/
directory. To create a new migration script after making changes to the models, run:
alembic revision --autogenerate -m "description"
To apply the migrations:
alembic upgrade head
For more information on using Alembic, refer to the Alembic documentation.
Contributions are welcome! If you find any issues or want to add new features, feel free to open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE
file for more information.
Feel free to modify and expand the `README.md` file based on your project's specific details and requirements.