Refactor for multi-provider architecture (#49)
authorStefan Gasser <redacted>
Mon, 19 Jan 2026 17:30:22 +0000 (18:30 +0100)
committerGitHub <redacted>
Mon, 19 Jan 2026 17:30:22 +0000 (18:30 +0100)
commit879fd9da06fb80149cb6961dbabe7755f948e84b
tree8e0ff62eedb2bbfa62236e61ade3df2186b6a246
parentd68cf3dc23092356bae71bcd82c39a33361fcde1
Refactor for multi-provider architecture (#49)

Reorganizes the codebase to support multiple LLM providers with a clean,
extensible architecture. This is a preparatory refactor that improves
code organization without adding new provider support.

Architecture changes:
- Move masking utilities to src/masking/ (conflict-resolver, placeholders, context)
- Add provider-specific directories: src/providers/openai/
- Create shared provider utilities: src/providers/errors.ts, src/routes/utils.ts
- Extract OpenAI-specific code to src/masking/extractors/openai.ts
- Add service layer: src/services/pii.ts, src/services/secrets.ts
- Move stream transformer to provider directory

New patterns:
- Provider-agnostic text extraction with TextExtractor interface
- Shared error handling with ProviderError class
- Centralized timeout constants in src/constants/timeouts.ts
- Unified logging helpers in src/routes/utils.ts

Removed:
- src/services/decision.ts (logic moved to service layer)
- src/providers/openai-client.ts (replaced by src/providers/openai/client.ts)

All 219 tests pass.
44 files changed:
CLAUDE.md
config.example.yaml
src/config.ts
src/constants/timeouts.ts [new file with mode: 0644]
src/index.ts
src/masking/conflict-resolver.test.ts [moved from src/utils/conflict-resolver.test.ts with 100% similarity]
src/masking/conflict-resolver.ts [moved from src/utils/conflict-resolver.ts with 100% similarity]
src/masking/context.test.ts [moved from src/utils/message-transform.test.ts with 70% similarity]
src/masking/context.ts [moved from src/utils/message-transform.ts with 66% similarity]
src/masking/extractors/openai.test.ts [new file with mode: 0644]
src/masking/extractors/openai.ts [new file with mode: 0644]
src/masking/placeholders.test.ts [moved from src/utils/placeholders.test.ts with 100% similarity]
src/masking/placeholders.ts [moved from src/utils/placeholders.ts with 93% similarity]
src/masking/service.ts [new file with mode: 0644]
src/masking/types.ts [new file with mode: 0644]
src/pii/detect.test.ts
src/pii/detect.ts
src/pii/mask.test.ts
src/pii/mask.ts
src/providers/errors.ts [new file with mode: 0644]
src/providers/local.ts [new file with mode: 0644]
src/providers/openai-client.ts [deleted file]
src/providers/openai/client.ts [new file with mode: 0644]
src/providers/openai/stream-transformer.test.ts [moved from src/services/stream-transformer.test.ts with 97% similarity]
src/providers/openai/stream-transformer.ts [moved from src/services/stream-transformer.ts with 95% similarity]
src/providers/openai/types.ts [new file with mode: 0644]
src/routes/health.ts
src/routes/info.ts
src/routes/openai.test.ts
src/routes/openai.ts
src/routes/utils.ts [new file with mode: 0644]
src/secrets/detect.ts
src/secrets/mask.test.ts
src/secrets/mask.ts
src/secrets/multimodal.test.ts
src/secrets/patterns/index.ts
src/secrets/patterns/types.ts
src/services/decision.test.ts [deleted file]
src/services/decision.ts [deleted file]
src/services/pii.ts [new file with mode: 0644]
src/services/secrets.ts [new file with mode: 0644]
src/test-utils/detection-results.ts
src/utils/content.test.ts
src/utils/content.ts
git clone https://git.99rst.org/PROJECT