A simple Book Shop REST API built with FastAPI, SQLAlchemy, Pydantic, and JWT authentication.
This project was built as a learning project to practice backend development with Python and FastAPI.
- 📚 Book CRUD operations
- 👤 User registration
- 🔐 User login
- 🎟️ JWT authentication
- 🔑 Password hashing with Argon2
- 📦 Pydantic request and response validation
- 🗄️ SQLite database
- 🧩 SQLAlchemy ORM
- 📖 Automatic API documentation with Swagger UI
- Python
- FastAPI
- Uvicorn
- SQLAlchemy
- Pydantic
- SQLite
- PyJWT
- pwdlib
- Argon2
book_shop/
│
├── app/
│ │
│ ├── books/
│ │ ├── models.py
│ │ ├── router.py
│ │ ├── schemas.py
│ │ └── service.py
│ │
│ ├── users/
│ │ ├── models.py
│ │ ├── router.py
│ │ ├── schemas.py
│ │ └── service.py
│ │
│ ├── core/
│ │ ├── deps.py
│ │ └── security.py
│ │
│ ├── database.py
│ └── main.py
│
├── .gitignore
├── requirements.txt
└── README.md
Clone the repository:
git clone https://github.com/siyametj/book_shop_api.gitMove into the project:
cd book_shop_apiCreate a virtual environment:
python3 -m venv venvActivate it:
source venv/bin/activatevenv\Scripts\activateInstall dependencies:
pip install -r requirements.txtStart the FastAPI server:
uvicorn app.main:app --reloadThe API will be available at:
http://127.0.0.1:8000
FastAPI automatically provides interactive API documentation.
http://127.0.0.1:8000/docs
http://127.0.0.1:8000/redoc
The API provides endpoints for managing books.
| Method | Endpoint | Description |
|---|---|---|
| GET | /books/ |
Get all books |
| GET | /books/{book_id} |
Get a specific book |
| POST | /books/ |
Create a book |
| PUT | /books/{book_id} |
Update a book |
| DELETE | /books/{book_id} |
Delete a book |
The API also provides user authentication.
| Method | Endpoint | Description |
|---|---|---|
| POST | /auth/register |
Register a new user |
| POST | /auth/login |
Login and receive an access token |
Authentication uses JWT access tokens.
The project currently uses SQLite as the database.
SQLAlchemy is used as the ORM for database operations.
The database tables are created when the application starts.
Passwords are hashed before being stored in the database.
The project uses:
- Argon2 for password hashing
- JWT for authentication tokens
The main goal of this project is to learn and practice:
- FastAPI
- REST API development
- HTTP methods
- Path parameters
- Query parameters
- Request and response models
- Pydantic validation
- Database integration
- Authentication
- JWT
- Password hashing
- API architecture
🚧 Learning project
The project is still under development and may receive new features and improvements.
Siyam
GitHub:
This project is licensed under the MIT License.