Files
breakpilot-compliance/dsms-gateway
Sharang Parnerkar a7fe32fb82 refactor(consent-sdk,dsms-gateway): split ConsentManager, types, and main.py
- consent-sdk/src/types/index.ts: extracted 438 LOC into core.ts, config.ts,
  vendor.ts, api.ts, events.ts, storage.ts, translations.ts; index.ts is now
  a 21-LOC barrel re-exporter
- consent-sdk/src/core/ConsentManager.ts: extracted normalizeConsentInput,
  isConsentExpired, needsConsent, ALL_CATEGORIES, MINIMAL_CATEGORIES into
  consent-manager-helpers.ts; reduced from 467 to 345 LOC
- dsms-gateway/main.py: extracted models → models.py, config → config.py,
  IPFS helpers + verify_token → dependencies.py, route handlers →
  routers/documents.py and routers/node.py; main.py is now a 41-LOC app
  factory; test mock paths updated accordingly (27/27 tests pass)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-18 08:42:32 +02:00
..

dsms-gateway

Python/FastAPI gateway to the IPFS-backed document archival store. Upload, retrieve, verify, and archive legal documents with content-addressed immutability.

Port: 8082 (container: bp-compliance-dsms-gateway) Stack: Python 3.11, FastAPI, IPFS (Kubo via dsms-node).

Architecture (target — Phase 4)

main.py (467 LOC) will split into:

dsms_gateway/
├── main.py          # FastAPI app factory, <50 LOC
├── routers/         # /documents, /legal-documents, /verify, /node
├── ipfs/            # IPFS client wrapper
├── services/        # Business logic (archive, verify)
├── schemas/         # Pydantic models
└── config.py

See ../AGENTS.python.md.

Run locally

cd dsms-gateway
pip install -r requirements.txt
export IPFS_API_URL=http://localhost:5001
uvicorn main:app --reload --port 8082

Tests

pytest test_main.py -v

Note: the existing test file is larger than the implementation — good coverage already. Phase 4 splits both into matching module pairs.

Public API surface

GET    /health
GET    /api/v1/documents
POST   /api/v1/documents
GET    /api/v1/documents/{cid}
GET    /api/v1/documents/{cid}/metadata
DELETE /api/v1/documents/{cid}
POST   /api/v1/legal-documents/archive
GET    /api/v1/verify/{cid}
GET    /api/v1/node/info

Every path is a contract — updating requires synchronized updates in consumers.