This FastAPI project is structured to provide a web application with functionalities around managing places and opinions about those places.
The project uses Poetry for dependency management. To install the project dependencies, use the command:
poetry install --no-root
To create tables in the database, use the command:
poetry run python -m fastapi_project.db.create_tables
To run the FastAPI application, use the command:
poetry run uvicorn fastapi_project.main:app --reload
The core module, specifically in pydantic_core.py and sqlalchemy_core.py, defines Pydantic models for data validation and SQLAlchemy models for database interactions, respectively. These models are essential for handling the data structure of places and opinions.
The db module contains scripts like create_db.py and create_tables.py for initializing the database and creating necessary tables.
The repositories module, found in repositories.py, implements the data access layer, providing an abstraction over the database operations for places and opinions.
The routers module defines the API routes for places and opinions. These routes handle HTTP requests and responses, interacting with the repositories to perform CRUD operations.
The tests module contains unit and integration tests for API endpoints and database operations, ensuring the reliability of the application.
The project leverages asynchronous routes, as seen in the routers, to handle HTTP requests. This asynchronous approach is beneficial for IO-bound operations, such as database interactions, improving the application's performance.
Tests are implemented using pytest-asyncio and async-asgi-testclient. To run the tests, use the command:
poetry run pytest
Migrations are managed through Alembic.