How ilyassultanov/sync-service works
Sync Service is a FastAPI backend that transfers records from internal system A to system B, supports manual and scheduled runs, and exposes run history, status, details, and errors. The principal workflow is API or scheduler → run creation → background execution → source fetch → per-record target push → persisted snapshots and results → API monitoring. The graph distinguishes orchestration, integrations, API contracts, and persistence. HTTP clients are documented as drop-in alternatives; their runtime wiring is not shown in the excerpts.
Main entry points: syncs.py Sync endpoints · sync_service.py Sync service · scheduler.py Periodic scheduler · sync_repository.py Sync repository
Components 18
API and contracts
- Sync endpoints
app/api/routes/syncs.py - API schemas
app/schemas/sync.py - App lifecycle
app/main.py
Sync execution
- Sync service
app/services/sync_service.py - Task runner
app/workers/tasks.py - Periodic scheduler
app/workers/scheduler.py - Runtime settings
app/config.py
System integrations
- Client interfaces
app/integrations/base.py - Mock source client
app/integrations/system_a_mock.py - Mock target client
app/integrations/system_b_mock.py - HTTP clients
app/integrations/http_clients.py
Persistence
- Sync repository
app/repositories/sync_repository.py - Run and item models
app/db/models/sync_run.py - Async DB session
app/db/base.py
Other components
- API caller
- System A
- System B
- PostgreSQL
Connections 24
- API caller → Sync endpoints: calls endpoints
README.md - Sync endpoints → Sync service: starts runs
app/api/routes/syncs.py - Sync endpoints → Task runner: schedules task
app/api/routes/syncs.py - Sync endpoints → Sync repository: queries runs
app/api/routes/syncs.py - Sync endpoints → API schemas: shapes responses
app/api/routes/syncs.py - App lifecycle → Sync endpoints: registers routes
app/main.py - App lifecycle → Periodic scheduler: starts scheduler
app/main.py - Periodic scheduler → Sync service: creates scheduled run
app/workers/scheduler.py - Periodic scheduler → Task runner: runs task
app/workers/scheduler.py - Task runner → Sync service: executes run
app/workers/tasks.py - Sync service → Sync repository: reads and writes
app/services/sync_service.py - Sync service → Client interfaces: uses clients
app/services/sync_service.py - Sync service → Mock source client: defaults to
app/services/sync_service.py - Sync service → Mock target client: defaults to
app/services/sync_service.py - Mock source client → System A: fetches records
README.md - Mock target client → System B: pushes records
README.md - HTTP clients → System A: fetches records
README.md - HTTP clients → System B: pushes records
README.md - Sync repository → Run and item models: manages records
app/repositories/sync_repository.py - Sync endpoints → Async DB session: obtains session
app/api/routes/syncs.py - Async DB session → PostgreSQL: connects to
app/db/base.py - Sync repository → PostgreSQL: persists run data
app/repositories/sync_repository.py - Periodic scheduler → Runtime settings: reads interval
app/workers/scheduler.py - Async DB session → Runtime settings: reads database URL
app/db/base.py