Backend for a habit tracker inspired by Atomic Habits. It exposes a REST API for creating and managing habits, with validation rules, optional Telegram reminders (Celery), and public habit listings.
- Habits CRUD — create, read, update, and delete habits (including “pleasant” habits and rewards).
- Serializer validation — e.g. cannot combine reward and associated pleasant habit; time cap; periodicity limits;
chat_idformat. - Reminders — Celery Beat can run periodic tasks (e.g. Telegram notifications).
- Public habits — habits can be marked public for sharing.
- Auth — JWT via
djangorestframework-simplejwt.
| Layer | Technology |
|---|---|
| API | Django REST Framework |
| DB | PostgreSQL |
| Tasks | Celery + django-celery-beat |
| Broker/cache | Redis |
| Docs (optional) | drf-yasg (Swagger/OpenAPI) |
habits/— models, serializers, views, tasks, permissions.users/— custom user model and auth-related endpoints.config/— Django settings, URLs, Celery app.
-
Clone the repo:
git clone https://github.com/AJLbN0H/atomic-habits-api.git cd atomic-habits-api -
Copy environment template and adjust secrets:
cp .env.sample .env
Set at least
SECRET_KEY, database credentials if you change them, andAPI_TELEGRAM_BOT_FATHERif you use Telegram. -
Start the stack:
docker compose up --build
API: http://localhost:8000 (migrations run in the
appservice command). -
Run tests inside Docker:
docker compose run --rm test
Secrets: do not commit real keys. Use
.env(ignored by git) or your host/CI secret store.docker-compose.ymlreads variables from the environment /.envfile in the project root.
You need PostgreSQL and Redis running locally (or tunneled). Match NAME, USER, PASSWORD, HOST, PORT, and Redis URLs in .env to your setup.
python -m venv .venv
.venv\Scripts\activate # Windows
# source .venv/bin/activate # Linux/macOS
pip install -r requirements.txt
cp .env.sample .env # then edit HOST=127.0.0.1 etc.
python manage.py migrate
python manage.py runserverOptional — if you use Poetry, install from pyproject.toml / lockfile (note: Docker and CI use requirements.txt as the canonical dependency list for parity).
celery -A config worker -l info
celery -A config beat -l infoGitHub Actions runs on pushes/PRs to main / develop: Python 3.13, PostgreSQL 15, Redis 7, then pip install -r requirements.txt and python manage.py test.
Workflow file: .github/workflows/tests.yml.
- More integration tests and coverage.
- Docker Secrets / external secret manager for production keys.
- Gamification (levels, streaks, etc.).