A clean architecture implementation of a command-line TODO list application in Python. This project demonstrates separation of concerns, dependency injection, and multiple storage options.
- ✅ Create, read, update, and delete tasks
- ✅ Mark tasks as completed
- ✅ Multiple storage options (in-memory or file-based)
- ✅ Clean Architecture principles
- ✅ Interactive and simple CLI modes
- ✅ Unit tests included
TO-DO List/
├── core/
│ ├── entities/ # Domain entities
│ │ ├── task.py # Task entity
│ │ └── repository.py # Repository interface
│ ├── usecases/ # Business logic
│ │ └── task_usecase.py
│ ├── interfaces/ # Interface adapters
│ │ └── cli/
│ │ └── cli_handler.py
│ └── infrastructure/ # External implementations
│ └── persistence/
│ ├── in_memory_repository.py
│ └── file_repository.py
├── entrypoints/ # Application entry points
│ ├── cli_main.py # Interactive CLI
│ └── simple_cli.py # Command-line arguments
├── tests/ # Unit tests
│ └── test_task_usecase.py
└── run.py # Demo script
This application follows Clean Architecture principles:
- Entities: Core business objects (Task)
- Use Cases: Application business rules (TaskUseCase)
- Interface Adapters: CLI handlers and presenters
- Infrastructure: External implementations (repositories)
- Clone the repository
- Ensure you have Python 3.7+ installed
- No external dependencies required (uses only standard library)
Run the interactive shell:
# In-memory storage (default)
python entrypoints/cli_main.py
# File-based storage
python entrypoints/cli_main.py --fileAvailable commands in interactive mode:
create <title> <description>- Create a new tasklist- List all tasksupdate <id> [--title=<title>] [--description=<desc>] [--completed=<true|false>]- Update a taskcomplete <id>- Mark task as completeddelete <id>- Delete a taskhelp- Show helpexit- Exit the application
Execute single commands:
# Create a task
python entrypoints/simple_cli.py create "Buy groceries" "Milk, bread, eggs"
# List all tasks
python entrypoints/simple_cli.py list
# Update a task
python entrypoints/simple_cli.py update 1 --title="Buy groceries updated"
# Complete a task
python entrypoints/simple_cli.py complete 1
# Delete a task
python entrypoints/simple_cli.py delete 1Run the demo to see the application in action:
python run.pyExecute the test suite:
python -m unittest tests/test_task_usecase.pyOr run all tests:
python -m unittest discover tests- Tasks are stored in memory and lost when the application closes
- Fast and suitable for testing
- Default option for
cli_main.py
- Tasks are persisted to
tasks.json - Data survives application restarts
- Used by
simple_cli.pyand optional incli_main.py
$ python entrypoints/cli_main.py
Using in-memory storage
Welcome to To-Do Application!
> create "Learn Python" "Study clean architecture"
Task created successfully (ID: 1)
> list
Tasks:
1 [○] Learn Python | Study clean architecture
Created: 2025-10-19 14:30
Updated: 2025-10-19 14:30
> complete 1
Task 'Learn Python' marked as completed
> exit
Goodbye!$ python entrypoints/simple_cli.py create "Meeting" "Team standup at 10am"
Task created with ID: 1
$ python entrypoints/simple_cli.py list
1. [○] Meeting - Team standup at 10am
$ python entrypoints/simple_cli.py complete 1
Task 1 completed
$ python entrypoints/simple_cli.py list
1. [✓] Meeting - Team standup at 10am- Repository Pattern: Abstract data access
- Dependency Injection: Loose coupling between components
- Use Case Pattern: Encapsulate business logic
- Abstract Base Classes: Define interfaces
- Database support (SQLite, PostgreSQL)
- Task priorities and due dates
- Task categories/tags
- Search and filter functionality
- REST API interface
- Web interface
This project is open source and available for educational purposes.
Feel free to fork this project and submit pull requests for improvements.