Domain Knowledge Management System - preprocessing toolset for heterogeneous text ingestion
Project description
Catalyst DKMS
Domain Knowledge Management System (DKMS) - A production-quality preprocessing toolset for heterogeneous text ingestion, analysis, and storage with PostgreSQL + pgvector.
Overview
DKMS is a CLI-first tool designed to:
- Ingest heterogeneous text files (txt, json, jsonl)
- Perform minimal analysis and domain classification
- Scrub PII (Privacy Information Identifier) data
- Generate embeddings for semantic search
- Store processed documents in PostgreSQL with pgvector
- Support graceful shutdown and resumable runs
- Provide structured logging and metrics
Features
- Format Detection: Automatic detection of txt, json, and jsonl formats
- PII Scrubbing: Pattern-based detection and redaction of emails and phone numbers
- Embeddings: Deterministic pseudo-random embedding generation (384-dim vectors)
- Classification: Multi-level classification (domain, category, subcategory)
- Deduplication: Content-hash based duplicate detection
- Resumable Runs: Checkpoint-based recovery from interruptions
- Structured Logging: JSON-formatted logs to stdout
- Docker Support: Fully containerized development environment
Quick Start
Prerequisites
- Python 3.11+
- Docker and Docker Compose
- Make (optional, for convenience)
Installation
- Clone the repository:
git clone https://github.com/ericmedlock/Catalyst_DKMS.git
cd Catalyst_DKMS
- Set up development environment:
make dev
source venv/bin/activate
- Start the database:
make db-up
- Run migrations:
make migrate
Basic Usage
Ingest documents from a directory:
python -m src.dkms.cli ingest --input ./unit_test/fixtures --safe true
View statistics:
python -m src.dkms.cli stats
Resume from checkpoint:
python -m src.dkms.cli resume
Docker Usage
Start all services:
docker-compose up -d
Run ingestion in container:
docker-compose exec app python -m src.dkms.cli ingest --input ./unit_test/fixtures --safe true
Configuration
Configuration follows precedence: CLI flags > Environment variables > YAML file
Default configuration is in configs/dkms.yaml. Override via environment variables:
export DKMS_DB_URL="postgresql://user:pass@localhost:5432/dkms"
export DKMS_INGEST_BATCH_SIZE=128
export DKMS_INGEST_SAFE_MODE=true
Configuration Reference
database:
url: "postgresql://dkms:dkms@localhost:5432/dkms"
pool_size: 5
max_overflow: 10
ingest:
batch_size: 64
safe_mode: true
supported_extensions:
- ".txt"
- ".json"
- ".jsonl"
resources:
min_threads: 1
max_threads: 4
embeddings:
provider: "local"
dimension: 384
classification:
provider: "local"
levels:
- "domain"
- "category"
- "subcategory"
pii:
enabled: true
patterns:
- "email"
- "phone"
Data Model
Tables
- documents: Core document metadata and content
- doc_embeddings: Vector embeddings (pgvector)
- doc_labels: Multi-level classification labels
- runs: Execution tracking
- checkpoints: Resume state
Key Features
- Content-hash based deduplication
- IVFFlat vector index for efficient similarity search
- JSONB fields for flexible metadata storage
Development
Running Tests
make test
Linting and Type Checking
make lint # Check code style
make format # Auto-format code
make type-check # Run MyPy
Database Migrations
Create a new migration:
alembic revision --autogenerate -m "description"
Apply migrations:
alembic upgrade head
Rollback:
alembic downgrade -1
Architecture
Component Overview
- cli.py: Click-based command-line interface
- config.py: Pydantic-based configuration management
- ingest.py: Main ingestion logic with signal handling
- io_detect.py: File format detection
- pii.py: PII scrubbing (regex-based stub)
- embeddings.py: Embedding provider interface
- classify.py: Classification provider interface
- db.py: Database session management
- models.py: SQLAlchemy ORM models
- resources.py: Resource monitoring
- util.py: Utility functions and logging
Signal Handling
DKMS handles SIGINT (Ctrl-C) and SIGTERM gracefully:
- Finishes processing current file
- Writes checkpoint
- Updates run status
- Exits cleanly
Resume from checkpoint with:
python -m src.dkms.cli resume
Testing
The test suite includes:
- test_io_detect.py: Format detection tests
- test_models.py: Database model tests
- test_ingest.py: End-to-end ingestion tests
Run with coverage:
pytest --cov=src.dkms --cov-report=html
CI/CD
GitHub Actions workflow runs on every push and PR:
- Linting (Ruff)
- Format check (Black)
- Type checking (MyPy)
- Unit tests (pytest)
- Integration tests with PostgreSQL + pgvector
Troubleshooting
Database Connection Issues
Ensure PostgreSQL is running and accessible:
docker-compose ps
PGPASSWORD=dkms psql -h localhost -U dkms -d dkms -c "SELECT version();"
Migration Errors
Reset database (development only):
docker-compose down -v
docker-compose up -d db
make migrate
Import Errors
Ensure PYTHONPATH is set:
export PYTHONPATH=/path/to/Catalyst_DKMS
License
MIT License - See LICENSE file for details
Contributing
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Run linting and tests
- Submit a pull request
Future Enhancements
- Production embedding providers (OpenAI, Cohere, etc.)
- Advanced PII detection (NER-based)
- ML-based classification models
- Streaming ingestion for large files
- Web UI for monitoring
- Multi-tenant support
- Advanced vector search capabilities
Contact
For questions or issues, please open a GitHub issue.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file catalyst_dkms-0.1.0.tar.gz.
File metadata
- Download URL: catalyst_dkms-0.1.0.tar.gz
- Upload date:
- Size: 15.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04009fe491e873b7f7bafe67d7ad2a5aa82287e9ce189aef9c146508065c05db
|
|
| MD5 |
d672bae57a8223da675d439197bc358e
|
|
| BLAKE2b-256 |
8119a538e42e80c734999fa432bb43a8cdafc37d8b7a5a796caf17e64f7c2a47
|
File details
Details for the file catalyst_dkms-0.1.0-py3-none-any.whl.
File metadata
- Download URL: catalyst_dkms-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41f64b5dd9a71f60a56fbffac0480630c29301eab442f2b0a3d7f6d6cc45a483
|
|
| MD5 |
72e4983976d37858d60eafc4943c7aca
|
|
| BLAKE2b-256 |
f63fdba60000b7c0467f54fa11ab0b592cd57d738f982f8df1ea20029a5a66b2
|