https://github.com/rahulsamant37/fastapi_clean-architecture
A production-ready Todo API built with FastAPI following clean architecture principles and best practices.
https://github.com/rahulsamant37/fastapi_clean-architecture
boilerplate-template continuous-integration docker docker-compose fastapi fastapi-crud fastapi-template help-others unittest
Last synced: 4 months ago
JSON representation
A production-ready Todo API built with FastAPI following clean architecture principles and best practices.
- Host: GitHub
- URL: https://github.com/rahulsamant37/fastapi_clean-architecture
- Owner: rahulsamant37
- License: gpl-3.0
- Created: 2025-05-05T16:39:58.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-09T15:00:30.000Z (about 1 year ago)
- Last Synced: 2025-07-04T00:37:32.875Z (11 months ago)
- Topics: boilerplate-template, continuous-integration, docker, docker-compose, fastapi, fastapi-crud, fastapi-template, help-others, unittest
- Language: Python
- Homepage:
- Size: 72.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FastAPI Clean Architecture Todo API
A production-ready Todo API built with FastAPI following clean architecture principles and best practices.
## ๐๏ธ Architecture
This project follows clean architecture principles, with clear separation of:
- **Entities** - Core business objects (`User`, `Todo`)
- **Use Cases** - Application business rules in services
- **Controllers** - HTTP request handlers
- **Infrastructure** - Database, authentication, and external interfaces
## ๐ Key Features
- Complete CRUD operations for Todos
- User authentication with JWT
- Password hashing with bcrypt
- Rate limiting
- PostgreSQL database with SQLAlchemy ORM
- Comprehensive test suite
- Docker support
- Clean code structure following best practices
## ๐ Getting Started
### Prerequisites
- Python 3.12+
- Docker and Docker Compose (optional)
- PostgreSQL (if running without Docker)
### Running with Docker
```bash
# Start the application and database
docker-compose up
```
The API will be available at `http://localhost:8000`
### Local Development Setup
```bash
# Create a virtual environment
python -m venv venv
source venv/bin/activate # Linux/macOS
venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements-dev.txt
# Configure environment variables
cp .env.example .env # Update with your values
# Run the application
uvicorn src.main:app --reload
```
## ๐ API Documentation
Once running, view the interactive API documentation at:
- Swagger UI: `http://localhost:8000/docs`
- ReDoc: `http://localhost:8000/redoc`
### Key Endpoints
- `POST /auth/` - Register new user
- `POST /auth/token` - Login and get access token
- `GET /todos/` - List all todos
- `POST /todos/` - Create new todo
- `GET /todos/{id}` - Get single todo
- `PUT /todos/{id}` - Update todo
- `DELETE /todos/{id}` - Delete todo
- `PUT /todos/{id}/complete` - Mark todo as complete
## ๐งช Testing
```bash
# Run all tests
pytest
# Run with coverage
pytest --cov=src
```
## ๐ ๏ธ Project Structure
```
src/
โโโ auth/ # Authentication logic
โโโ database/ # Database configuration
โโโ entities/ # Domain entities
โโโ todos/ # Todo feature module
โโโ users/ # User feature module
โโโ exceptions.py # Custom exceptions
โโโ logging.py # Logging configuration
โโโ main.py # Application entry point
```
## ๐ Security Features
- JWT authentication
- Password hashing with bcrypt
- Rate limiting on registration endpoint
- CORS protection
- Input validation with Pydantic
## ๐ค Contributing
1. Fork the repository
2. Create a new branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.