Building a Habit Tracker CLI in Python

For my Object-Oriented and Functional Programming module at IU, I built a Habit Tracker CLI in Python. Here’s how the project went, what tools I used, and what I learned.

As part of the course Object Oriented and Functional Programming with Python in university I was instructed to create a simple habit tracking app that can be accessed via a CLI which demonstraing object oriented programming and functional programming concepts.

The project is available on GitHub:
👉 valentinweyer/iu-oop-fp-portfolio

Core Functionality

  • Access via command-line interface
  • Creating and deleting habits
  • Managing active habits
  • Analyzing progress and streaks

Tech Stack

To meet the requirements, I built the project with:

  • Python 3.12+
  • SQLAlchemy – ORM for database management (SQLite backend).
  • Click – for building the command-line interface.
  • Rich – to improve CLI output readability.
  • PyTest – for automated testing.

Design Decisions

To demonstrate OOP, I created:

  • A base Habit class for shared logic.
  • Subclasses for daily and weekly habits, showing inheritance and polymorphism.

To incorporate FP, I used:

  • Higher-order functions and map/filter for certain data processing tasks.
  • Lambda expressions for short inline operations.

Challenges

  • Datetime handling: I initially mixed date and datetime objects, which led to subtle bugs until I standardized my approach.
  • CLI styling: Making the CLI’s help text user-friendly required digging deeper into Click.
  • Testing: Setting up proper tests with PyTest was time-consuming but worth it — they caught regressions quickly.

What I’m Proud Of

The extensible habit system is the feature I value most. It allows for:

  • Easy addition of new habit types
  • Precision in tracking
  • A showcase of how thoughtful design principles (OOP + FP) translate into maintainable, adaptable software

Example CLI Usage

Add a habit

Add Habit

Complete a task

Complete Task

Delete a habit

Delete Habit

Show all habits

Show All Habits

Show all habit instances

Show All Habit Instances

Running streak

Running Streak