This is a minimalist FastAPI backend designed to manage library records. It provides a RESTful interface and persists data using a PostgreSQL database.
- Python 3.8+
- PostgreSQL
pip(latest version)
The application uses environment variables for configuration. Create a file named .env in the root directory:
DATABASE_URL=postgresql://user:password@localhost:5432/library_dbFollow these steps to prepare your local environment:
Update pip and install the required packages:
python3 -m pip install --upgrade pip
pip install -r requirements.txtInitialize the PostgreSQL schema and populate the database with initial data:
python3 seed.py| Method | Endpoint | Description |
|---|---|---|
| POST | authors | Create Author |
| GET | authors | Read Authors |
| GET | /authors/{author_id} | Read Author |
| Method | Endpoint | Description |
|---|---|---|
| POST | books | Create Book |
| GET | books | Read Books |
| GET | /books/{book_id} | Read Book |
| PATCH | /books/{book_id} | Update Book |
| DELETE | /books/{book_id} | Delete Book |
Launch the development server using the FastAPI CLI:
fastapi devThe API will be available at http://localhost:8000. You can access the auto-generated documentation (Swagger UI) at http://localhost:8000/docs.