This is the backend API for the Pecha application.
Follow these steps to set up the project on your local machine:
- Clone the repository:
git clone https://github.com/yourusername/pecha_api.git
- Navigate to the project directory:
cd pecha_api
- Install the dependencies:
poetry install
- Navigate to the local setup directory:
cd local_setup
- Start the database using Docker:
docker-compose up -d
- Apply database migrations:
poetry run alembic upgrade head
- Start the FastAPI development server:
poetry run uvicorn pecha_api.app:api --reload
The application will be available at http://127.0.0.1:8000/
.
You can access the Swagger UI for the API documentation at http://127.0.0.1:8000/docs
. sh poetry install
To run tests, execute the following command:
sh poetry run pytest
To check the coverage:
sh poetry run pytest --cov=pecha_api
sh poetry run coverage html
Open the coverage report:
sh open htmlcov/index.html
### Alembic Commands
Alembic is used for handling database migrations. Here are some common commands:
1. Create a new migration:
```sh
poetry run alembic revision --autogenerate -m "description of migration"
```
2. Apply the latest migrations:
```sh
poetry run alembic upgrade head
```
3. Downgrade to a previous migration:
```sh
poetry run alembic downgrade -1
```
4. View the current migration history:
```sh
poetry run alembic history
```
5. Show the current migration state:
```sh
poetry run alembic current
```