A modern RESTful API for library management, built with FastAPI and PostgreSQL.
Bibliotheque API is a robust backend application for managing books, users, and associated tags. It provides a complete API interface for CRUD (Create, Read, Update, Delete) operations on the main resources of a library.
- Book management
- User management
- Tag/category system
- PostgreSQL database
- Data validation with Pydantic
- Automatic API documentation with Swagger UI
Before you start, make sure you have installed:
- Python ≥ 3.11.9
- PostgreSQL ≥ 12
- uv for dependency management
- Git
Windows (with winget):
winget install astral-sh.uvmacOS / Linux:
curl -LsSf https://astral.sh/uv/install.sh | shgit clone <repository-url>
cd bibliotheque-apiuv syncThis command will automatically create a virtual environment (.venv) and install all dependencies.
See the provided .env.example file and create a .env file at the root of the project:
SUPABASE_DB_URL=postgresql+psycopg://postgres:<password>@db.<project>.supabase.co:5432/postgres
secret_key = "<your_secret_key>"
algorithm = "HS256"
access_token_expire_minutes = 70
ADMIN_EMAIL = "<admin@email.com>"
ADMIN_PASSWORD = "<admin_password>"
Admin_Username = "admin"
OpenLibrary_URL = "https://openlibrary.org"
GoogleBooks_URL = "https://www.googleapis.com/books/v1/volumes?q=isbn:"Replace the values with those from your Supabase project and your secrets.
python -m app.main├── app
│ ├── core
│ │ ├── auth.py
│ │ └── security.py
│ ├── models
│ │ ├── Books.py
│ │ ├── tags.py
│ │ └── users.py
│ ├── routers
│ │ ├── auth.py
│ │ ├── books.py
│ │ ├── tags.py
│ │ └── users.py
│ ├── schemas
│ │ ├── Books.py
│ │ ├── tags.py
│ │ └── users.py
│ ├── database.py
│ └── main.py
├── .env.example
├── .gitignore
├── README.md
├── pyproject.toml
└── uv.lock
GET /books/- Retrieve all books
GET /users/- Retrieve all users
GET /tags/- Retrieve all tags
GET /- Welcome message
uv run python -m uvicorn app.main:app --reloadThe application will be available at: http://localhost:8000
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
| Package | Version | Purpose |
|---|---|---|
| fastapi | ≥0.128.0 | Asynchronous web framework |
| sqlalchemy | ≥2.0.46 | ORM for database interactions |
| psycopg[binary] | ≥3.3.2 | PostgreSQL driver |
| pydantic | ≥2.12.5 | Data validation |
| uvicorn | ≥0.40.0 | ASGI server |
| python-dotenv | ≥1.2.1 | Environment variable management |
| python-jose | ≥3.5.0 | JWT management |
| pytest | ≥9.0.2 | Testing framework |
| passlib | ≥1.7.4 | Password hashing |
| bcrypt | =4.0.1 | Password hashing (backend) |
| requests | ≥2.32.5 | HTTP requests |
| ruff (dev) | ≥0.15.1 | Linter/formatter (dev only) |
The application follows a layered modular architecture:
- Routers: HTTP entry points
- Models: Database schemas (SQLAlchemy)
- Database: Connection and session configuration
- Main: FastAPI initialization and global configuration
For any questions or issues, please open an issue in the repository.