Skip to content

Add DuckDB as configurable storage backend for work events#10

Open
prithvianilk wants to merge 1 commit intomainfrom
feature/duckdb-storage-backend
Open

Add DuckDB as configurable storage backend for work events#10
prithvianilk wants to merge 1 commit intomainfrom
feature/duckdb-storage-backend

Conversation

@prithvianilk
Copy link
Owner

Summary

  • Adds DuckDB as an alternative storage backend for work events
  • Introduces abstract factory pattern (StorageFactory) to centralize backend selection
  • Backend configurable via STORAGE_BACKEND environment variable (pinot or duckdb)
  • Default remains pinot for backward compatibility

Changes

  • New file: web-app/storage_factory.py - Abstract factory with PinotStorageFactory and DuckDBStorageFactory
  • Modified: web-app/work_repo.py - Added DuckDBWorkRepo class with all 8 query methods
  • Modified: web-app/services/work_ingestion_service.py - Added DuckDBWorkIngestionService class
  • Modified: web-app/api.py - Now uses StorageFactory pattern
  • Modified: mcp-server/main.py - Now uses StorageFactory pattern
  • Modified: pyproject.toml - Added duckdb>=0.9.0 dependency

Test plan

  • Set STORAGE_BACKEND=duckdb in web-app/config.env
  • Run pip install -e . to install duckdb dependency
  • Start web app: cd web-app && python api.py
  • POST to /api/work with sample work event
  • GET /api/v1/main-page-data?since_time=0 to verify queries work
  • Verify DuckDB file created: duckdb kelsa_work.duckdb -c "SELECT * FROM work LIMIT 5"
  • Set STORAGE_BACKEND=pinot and verify Pinot backend still works

🤖 Generated with Claude Code

Introduces an abstract factory pattern (StorageFactory) to support both
Pinot and DuckDB backends. Backend selection is controlled via the
STORAGE_BACKEND environment variable ('pinot' or 'duckdb').

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

def initialize(self) -> None:
conn = duckdb.connect(self.db_path)
conn.execute(
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO:
Move this outside of code.

@prithvianilk prithvianilk requested a review from abhiy13 January 13, 2026 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant