Build a command-line application that imports lesson activity from CSV, validates and stores it in SQLite, calculates progress summaries, exports JSON, and optionally synchronizes completed lesson identifiers with a remote API. The project remains useful without network access and has explicit boundaries for files, database work, and HTTP.
Completion means a fresh virtual environment can install the built wheel, run the command, pass automated tests, reject malformed or duplicate data safely, produce useful logs, and follow a documented deployment and rollback procedure.
pyproject.toml
src/progress_report/
cli.py
domain.py
import_csv.py
repository.py
sync_api.py
tests/
unit/
integration/
The src layout prevents tests from accidentally importing an uninstalled package from the repository root.
Represent status with an enum and parsed timestamps with datetime values. Keep CSV strings and SQLite rows at adapters so calculations operate on validated domain data.
from dataclasses import dataclass
from datetime import datetime
from enum import StrEnum
class Status(StrEnum):
STARTED = "started"
COMPLETED = "completed"
@dataclass(frozen=True)
class Progress:
lesson: str
status: Status
completed_at: datetime | None = None
The importer decides whether a raw status and timestamp can construct this record.
Use parameterized queries, enable foreign keys for each SQLite connection, and import one file inside a transaction so a failed row does not leave an unexplained partial batch.
| Table | Essential Rule |
|---|---|
| learners | Canonical email is unique |
| lessons | External lesson identifier is unique |
| progress | One learner and lesson pair is unique |
| sync_events | Stable request key prevents duplicate remote work |
progress-report import activity.csv --learner maya@example.com
progress-report summary --learner maya@example.com
progress-report export report.json --learner maya@example.com
progress-report sync --learner maya@example.com --dry-run
A dry run prints intended synchronization without sending data and must not mark events as delivered.
After the acceptance evidence passes, add a process pool for a measured CPU-heavy report, a small web API, or encrypted backup export. Each extension must preserve offline behavior and the existing data contract.
0 of 2 checked
Try this next
0 of 2 completed
Explore 500+ free tutorials across 20+ languages and frameworks.