A REST API for managing tasks and categories, built with FastAPI and PostgreSQL.
To get a local copy up and running, follow these steps.
- Python 3.10 or higher
- PostgreSQL 13 or higher
- pip or another Python package manager
- Clone the repository
git clone https://github.com/h8nix/faspt_project.git
cd faspt_project- Create and activate a virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies
pip install -r requirements.txt- Set up environment variables
Create a .env file in the root directory and configure your database URL:
DATABASE_URL=postgresql+asyncpg://user:password@localhost:5432/task_manager- Create database tables
python3 -c "from faspt.app.db.session import engine; from faspt.app.models.base import Base; Base.metadata.create_all(bind=engine)"- Start the application
uvicorn faspt.app.main:app --reloadThe API will be available at http://localhost:8000
Interactive API documentation can be accessed at http://localhost:8000/docs
uvicorn faspt.app.main:app --reloadStarts the development server with auto-reload enabled. Changes to the code will automatically reload the server.
uvicorn faspt.app.main:appStarts the server in production mode without auto-reload.
faspt/app/
├── main.py FastAPI application entry point
├── core/
│ ├── config.py Configuration management
│ └── exceptions.py Domain-specific exceptions
├── api/ HTTP routing layer
│ ├── categories.py
│ └── tasks.py
├── services/ Business logic layer
│ ├── category.py
│ └── task.py
├── repositories/ Data access layer
│ ├── interfaces.py
│ ├── category.py
│ └── task.py
├── models/ SQLAlchemy ORM models
│ ├── base.py
│ ├── category.py
│ └── task.py
├── schemas/ Pydantic validation schemas
│ ├── category.py
│ └── task.py
└── db/
└── session.py Database connection management
This project demonstrates clean architecture principles with clear separation of concerns:
- HTTP Layer (api/): Handles incoming requests and responses
- Business Logic Layer (services/): Contains application logic independent of HTTP
- Data Access Layer (repositories/): Manages database operations
- Domain Models (models/): SQLAlchemy ORM definitions
- Configuration (core/): Settings and error definitions
The services layer uses dependency injection to accept repository interfaces rather than concrete implementations. This makes the code testable and maintainable.
POST /categories/ Create a new category
GET /categories/ Get all categories
GET /categories/{id} Get a category by ID
PATCH /categories/{id} Update a category
DELETE /categories/{id} Delete a category
POST /tasks/ Create a new task
GET /tasks/ Get all tasks
GET /tasks/{id} Get a task by ID
PATCH /tasks/{id} Update a task
DELETE /tasks/{id} Delete a task
Configuration is handled through environment variables defined in .env files.
.env.example- Template with all available configuration options.env.development- Development configuration.env.testing- Test environment configuration.env.production.example- Production configuration template
| Variable | Description | Example |
|---|---|---|
| ENVIRONMENT | Deployment environment | development, testing, production |
| DEBUG | Enable debug mode | true, false |
| DATABASE_URL | PostgreSQL connection string | postgresql+asyncpg://user:password@localhost:5432/db |
| SECRET_KEY | Secret key for authentication | your-secret-key |
| CORS_ALLOWED_ORIGINS | Allowed CORS origins | ["http://localhost:3000"] |
- fastapi 0.135.1 - Web framework
- sqlalchemy 2.0.48 - ORM and database toolkit
- asyncpg 0.31.0 - PostgreSQL async driver
- pydantic 2.13.2 - Data validation
- pydantic-settings 2.13.1 - Settings management
- uvicorn 0.44.0 - ASGI server
See requirements.txt for the complete list.
This REST API was specifically designed and developed to serve the Todo App frontend client.
- Frontend Repository: todo-app-frontend
- Frontend Developer: @makedonsky-it
The frontend application seamlessly integrates with these API endpoints, handling tasks and categories through the provided CORS configuration.
The following features are planned for future development:
- Implement Alembic database migrations for version control
- Add comprehensive test suite with Pytest and pytest-asyncio
- Implement Docker containerization with Docker Compose
- Deploy to production environments (Heroku, AWS)
This project is licensed under the MIT License - see the LICENSE file for details.
- Backend Development: @h8nix
- Frontend Development: @makedonsky-it
This project is licensed under the MIT License - see the LICENSE file for details.