A fully tested FastAPI-based backend service that allows users to track their habits, completion status, and progress — with full CRUD functionality, user authentication, and admin capabilities.
Built in 6 days using modern Python tools and best practices. Fast, clean, and powerful.
- FastAPI – for blazing-fast API development
- Uvicorn – lightning-fast ASGI server
- SQLModel – SQLAlchemy + Pydantic
- Alembic – schema migrations
- PostgreSQL – rock-solid relational DB
- Pydantic – data validation and serialization
- python-dotenv – environment management
- JWT (python-jose) – secure token-based authentication
- Git – version control
- Pytest – testing framework
- Create a user
- Update user info
- Delete own account
- Admin-only:
- View all users
- Get user by ID
- Get user by username
- JWT-based login via
/login - Secure endpoints require token in
Authorization: Bearer <token>
- Create a habit
- Get all habits
- Optional filtering by
categoryand/orfrequency(enums)
- Optional filtering by
- Get habit by ID
- Get habit by name
- Update a habit
- Delete a habit
- Mark a habit as completed today
- Get today's completion status
- Get all past completion dates
Structured and comprehensive test coverage for routers and CRUD logic.
test_route_users.pytest_route_habits.pytest_route_auth.py
test_crud_users.pytest_crud_habits.pytest_crud_completions.py
conftest.py– global test fixturesconftest_crud.py– CRUD-specific fixturestest_helpers.py– shared helper functions (e.g. token generation)
To run all tests:
pytest- clone the repo
- Create a PostgreSQL database
- Create a
.envfile in the root with:
DATABASE_URL=postgresql+psycopg2://<user>:<password>@<host>:<port>/<db>
SECRET_KEY=your-secret-key- Install dependencies
pip install -r requirements.txt- Run migrations
alembic upgrade head- Run the server
uvicorn app.main:app --reload- Open your browser at:
http://localhost:8000/docs→ Interactive Swagger UI to test all endpoints
- POST to /login with valid user credentials
- You'll receive a JWT token
- Use this token for all authenticated endpoints:
Authorization: Bearer <your_token_here>- All habit endpoints require authentication.
- Admin routes are protected and require a user with is_admin=True.
- Thoroughly tested for edge cases, invalid inputs, and permission errors.
- Add user registration confirmation via email
- Implement email reminders based on
reminder_timeandfrequency - Provide user analytics and statistics for admins
- Dockerize the application for easier deployment
💻 Passionate backend developer
MIT License. Use it, fork it, break it, improve it.