Skip to content

Refactor backend into a reliable modular monolith - #17

Open
simajkeee wants to merge 7 commits into
sputnik-llc:mainfrom
simajkeee:refactor
Open

Refactor backend into a reliable modular monolith#17
simajkeee wants to merge 7 commits into
sputnik-llc:mainfrom
simajkeee:refactor

Conversation

@simajkeee

Copy link
Copy Markdown

Summary

Refactors the FastAPI backend into clear HTTP, application, persistence, storage, and background-processing boundaries while preserving the public API contract.

What changed

  • Split HTTP routes into api/files.py and api/alerts.py.
  • Added request-scoped dependency assembly and centralized domain-error handlers.
  • Extracted file and alert repositories from application workflows.
  • Added FileService and ProcessingService use cases.
  • Moved filesystem access into FileStorage.
  • Added streamed uploads, temporary-file cleanup, atomic promotion, and DB-failure compensation.
  • Replaced the three-step Celery chain with one process_file task.
  • Created the worker async engine/session factory in the worker event loop.
  • Added row locking, terminal-state guards, and alert de-duplication for retry-safe processing.
  • Added query indexes for file and alert list/FK queries.

Verification

uv run ruff check src tests migrations
env -u POSTGRES_USER -u POSTGRES_PASSWORD -u POSTGRES_DB -u POSTGRES_HOST -u PGPORT uv run pytest
POSTGRES_HOST=localhost uv run alembic upgrade head

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