A streamlined Django backend to ingest external content, match it against user-defined keywords, and manage a human review workflow with smart suppression.
- Separation of Concerns: Business logic (scoring and suppression) is strictly isolated in
services.py. Django Views only manage the HTTP layer, and Models only manage data representation. - Database Choice: SQLite is used as requested for simplicity, but the ORM queries and
transaction.atomic()blocks are production-ready for PostgreSQL. - Content Ingestion: A
ContentFetcherstrategy pattern is used. I opted for the local mock JSON dataset to ensure the assignment remains self-contained, runnable, and verifiable without relying on external API uptimes or rate limits.
- Scoring Logic:
- Score 100: Implemented via regex
\bkeyword\bto guarantee exact whole-word matching in the title (e.g., "Python" matches "Python Framework" but not "Pythonista"). - Score 70: Substring matching in the title.
- Score 40: Keyword appears in the body (and not the title).
- Score 100: Implemented via regex
- Suppression Logic:
- Flags are unique to a
(Keyword, ContentItem)pair to naturally de-duplicate flags. - If a user patches a flag's status to
irrelevant, it will remainirrelevantacross subsequent scans. - However, if the
last_updatedtimestamp of theContentItemfrom the fetcher is newer than the database timestamp, the DB is updated, and anyirrelevantflags tied to it are reverted back topending.
- Flags are unique to a
- Clone & Virtual Environment:
python -m venv venv source venv/bin/activate pip install django djangorestframework python-dateutil