A complete CRUD system for managing books, developed with FastAPI and SQLite, Docker-ready.
- Full CRUD operations (Create, Read, Update, Delete)
- Data validation with Pydantic
- SQLite database
- Logging with Loguru
- Automatic documentation (Swagger UI and Redoc)
- Ready for containerization with Docker
- Python
- FastAPI
- SQLAlchemy
- Pydantic
- Uvicorn
- SQLite
- Poetry
- Docker
- Loguru
- Git
- Python 3.12+
- Poetry (Dependency manager)
- Docker (optional)
git clone https://github.com/Rodrigomattos93/projeto_crud.git
cd projeto_crudLocally:
poetry install --no-root
poetry env activate
uvicorn app.main:app --reloadWith Docker:
docker build -t livro-crud .
docker run -d --name livro-crud -p 8000:8000 livro-crudThe API documentation will be available at:
- Swagger UI: `http://localhost:8000/docs`
- Redoc: `http://localhost:8000/redoc`| Método HTTP | Endpoint | Descrição |
|---|---|---|
GET |
/books/ |
List all books |
GET |
/books/{id} |
Gets a specific book |
POST |
/books/ |
Creates a new book |
PUT |
/books/{id} |
Update an existing book |
DELETE |
/books/{id} |
Delete a book |
class BookModel(Base):
__tablename__ = "books"
id = Column(Integer, primary_key=True, index=True)
title = Column(String, index=True)
author = Column(String, index=True)
publication_year = Column(Integer, nullable=True)
genre = Column(String, nullable=True)
publisher = Column(String, nullable=True)
page_count = Column(Integer, nullable=True)
description = Column(String, nullable=True)
is_avaiable = Column(Boolean)
created_at = Column(DateTime, default=func.now())├── app/
│ ├── controllers.py # Lógica de negócios
│ ├── db.py # Configuração do banco
│ ├── logger_config.py # Configuração de logs
│ ├── main.py # Ponto de entrada
│ ├── models.py # Modelos do banco
│ ├── routers.py # Endpoints
│ └── schemas.py # Validação
├── Dockerfile # Config Docker
├── pyproject.toml # Dependências
├── books.db # Banco de dados
└── README.md # Documentação
The application is hosted on Render and can be accessed at the following link