Skip to content

AI Todo App: A Task Manager Where the AI Is Optional

AITodoApp is a self-hosted task manager: a FastAPI server, one SQLite file and a single-page dashboard. Claude can turn a typed sentence into a structured task. Nothing else depends on it.

The source is on my Forgejo: git.mocipher.com/m01/AITodoApp.

The repo has had three shapes. It started in November 2025 as a scaffold with placeholder code. In February 2026 it was a short command-line script on OpenAI. In July 2026 I rewrote it on FastAPI, SQLite and Claude. That rewrite is what this post describes.

What it does

  • Tasks with a title, description, one of four priorities, a category and a due date. Tasks can be pinned to the top.
  • Recurring tasks: daily, weekly, biweekly or monthly. Completing one creates the next copy, due one interval later.
  • Subtasks with a progress bar, tags, and a start/stop timer per task.
  • A stats row (pending, done, overdue, due today, streak, time tracked) and a seven-day chart of completed tasks.
  • JSON and CSV export, and a daily digest posted to a Discord or Slack webhook. digest.py is meant to run from cron.
  • A terminal menu, app.py, that works on the same database.

How it is built

About 1,600 lines of Python in five files, no ORM and no build step.

  • server.py defines 36 endpoints under /api plus the page itself. FastAPI generates the OpenAPI docs at /docs.
  • database.py uses the standard sqlite3 module. Seven tables: tasks, subtasks, time entries, tags, a task-to-tag join table, an activity log and the digest settings. Foreign keys are on, so deleting a task also deletes its subtasks, timer entries and tag links.
  • The dashboard is one Jinja template, about 600 lines of plain JavaScript and 730 lines of CSS. It talks to the same REST API as any other client. Dark theme by default, keyboard shortcuts for the common actions.

Where the AI fits, and where it does not

All of it lives in ai_engine.py: four functions, each making one call to the Anthropic Messages API with claude-sonnet-4-20250514. Three of them ask for JSON only and parse the reply.

  • Parse. The sentence goes in with today's date and weekday, so "by Friday" can become a real date. Back come title, description, priority, category, due date and recurrence. Priority and recurrence are checked against the allowed values. If the reply is not valid JSON, the sentence is saved as a plain task.
  • Suggest. Sends the open tasks and asks for three new ones, each with a reason. Nothing is added until I click Add.
  • Prioritize. Sends the open tasks with IDs and due dates and gets back an order and a short explanation. It only displays the order. It changes nothing.
  • Time. Sends tracked time per task and asks for a three to four sentence summary.

Without ANTHROPIC_API_KEY, the client is never created. The sentence becomes the task title with medium priority, and the AI buttons show a message asking for a key. Lists, timers, stats, export and the digest work the same either way.

Running it

git clone https://git.mocipher.com/m01/AITodoApp.git
cd AITodoApp
python3 -m venv .venv && . .venv/bin/activate
pip install -r requirements.txt "starlette<1"
cp .env.example .env   # optional: put ANTHROPIC_API_KEY here
uvicorn server:app --host 127.0.0.1 --port 8000
# dashboard: http://127.0.0.1:8000   API docs: /docs

curl -X POST http://127.0.0.1:8000/api/tasks \
  -H "Content-Type: application/json" \
  -d '{"title": "Renew TLS certificates", "priority": "high", "due_date": "2026-11-02"}'

The Starlette pin is a workaround. The first item below explains it.

What I'd do next

The gaps are concrete. Each of these is in the code today.

  • Pin dependencies. requirements.txt only sets minimum versions. A fresh install today pulls Starlette 1.x, where the template call in server.py no longer works, and the dashboard returns a 500.
  • Write tests. There are none. The first scaffold had three test files, they were removed in February, and the rewrite added none. A few API tests would have caught the three bugs that follow.
  • Fix bulk complete. The route /api/tasks/{task_id}/complete is declared first and catches /api/tasks/bulk/complete, so the bulk request gets a 422 and the Complete button shows a success message while completing nothing. Bulk delete works.
  • Fix timer time zones. SQLite stores the start time in UTC, the stop is measured against local time. With the clock on Central European Time, a two-second timer was saved as 3,602 seconds.
  • Validate input and close connections. An unknown priority hits a database constraint and returns a 500. That connection is never closed, so the next write waits five seconds and fails with "database is locked".
  • Move to a current model. The code pins claude-sonnet-4-20250514, a model from May 2025. Changing the string is not enough: the code reads the first content block as text and trusts the model to return bare JSON. Structured outputs would remove that guesswork.
  • Lock it down. python server.py listens on all interfaces with no authentication, and the digest webhook URL can be read back from the API. The dashboard also puts a task's category into the page without escaping it, so a crafted task can run script in the browser of whoever opens the list.
  • Make the README match the code. The digest send time is saved, but nothing acts on it because cron decides when it runs, and the MIT badge has no LICENSE file behind it.