Assignment: Build a Personal Knowledge Manager using Python
Fundamentals
Project Summary
Build a command-line Personal Knowledge Manager (PKM) — a tool to create, store, manage,
and search personal notes. This project will help you apply core Python concepts in a structured,
real-world use case, without relying on any external libraries or frameworks.
The application will store notes in a local file, allow searching and tagging, and include utilities
like undo, logging, and performance tracking.
Requirements
- Use only Python’s standard library
- Organize code modularly across multiple files
- Write clean, idiomatic, and readable Python
- Use OOP to model the data (like notes)
- Persist data using file handling
- Implement custom decorators, generators, and context managers
- Handle all errors gracefully using custom exceptions.
Features to Implement
Note Creation, Editing, Deletion
Allow users to input a note title, content, and tags. Notes should be saved to a file (`notes.txt`).
Each note should be represented as a class object.
Tag-Based Search
Allow searching notes by one or more tags. Show matching notes using filtered list
comprehension.
Undo Last Action
Implement an undo stack to revert the last operation (e.g., delete or add). Use a custom
exception to handle invalid undo operations.
Logging and Timing
Create a `@logger` decorator to log actions to a file. Create a `@timer` decorator to print
function execution time.
Lazy Note Loader
Implement a generator function to read notes from a file lazily. Useful for performance when
notes grow large.
Custom Context Manager for File Handling
Use `__enter__` and `__exit__` to manage file I/O safely. Wrap file write/read operations inside
this class.
Operator Overloading in Note Class
Use `__str__`, `__eq__`, etc., to improve how Note objects behave and are printed.
What You Can Use
Python Standard Library Only
os, time, datetime, functools, typing
List/dict/set comprehensions
OOP: classes, inheritance, dunder methods
File I/O: open/read/write
Decorators and context managers
Iterators/generators
Exception handling and custom exceptions
What You Should NOT Use
Any third-party packages (e.g., pandas, requests, numpy)
Any web frameworks (Flask, FastAPI, Django)
Any database or ORM (use flat files only)
This task is meant to demonstrate mastery of Python fundamentals without shortcuts. You’ll be
evaluated based on the code quality, modularity, and effective use of core Python features.