How londonaicentre/flip works
Purpose and Top-Level Entry Points
FLIP is a monorepo for privacy-preserving federated training/evaluation of medical-imaging models across institutional “trusts.” The local operational entry point is Makefile, which launches Compose/Swarm stacks from deploy/compose.development.yml; backend-specific FL provisioning and execution start in fl-services/nvflare/Makefile or fl-services/flower/Makefile. The user-facing system is a Vue SPA backed by a Python/FastAPI Central Hub.
Central Hub: Control Plane
flip-api/src/flip_api/main.py is the FastAPI entry point. It owns persistent platform state—users, roles, trusts, projects, models, FL scheduling and audit data—through flip-api/src/flip_api/db/database.py and flip-api/src/flip_api/db/models/main_models.py. Domain schemas/interfaces form the service boundary at flip-api/src/flip_api/domain/schemas/ and flip-api/src/flip_api/domain/interfaces/.
Hub services implement project lifecycle, trust registration/health, model/file management, cohort requests, and FL orchestration:
• flip-api/src/flip_api/project_services/
• flip-api/src/flip_api/fl_services/services/fl_scheduler_service.py
• flip-api/src/flip_api/trusts_services/services/register_trust.py
Identity, Security, and Hub-to-Trust Boundary
The hub authorizes users and trust callers via flip-api/src/flip_api/auth/access_manager.py and dependency wiring in flip-api/src/flip_api/auth/dependencies.py. Trusts receive per-trust API keys during registration and communicate outward to the hub; the hub maintains task-oriented integration paths in flip-api/src/flip_api/private_services/trust_tasks.py. AWS-oriented integrations include Cognito, S3 presigned/file operations, SES, and Step Functions, visible in flip-api/src/flip_api/utils/cognito_helpers.py, flip-api/src/flip_api/utils/s3_client.py, and flip-api/src/flip_api/step_functions_services/.
Web Client
The SPA starts at flip-ui/src/main.ts, with routing in flip-ui/src/router/index.ts and root composition in flip-ui/src/App.vue. Page-level flows cover authentication/admin, projects, cohort queries, and model training; service clients isolate API calls under flip-ui/src/services/. The UI is a Vue 3/TypeScript application and can be containerized (flip-ui/Dockerfile); AWS deployment serves it from S3/CloudFront rather than necessarily running a UI container.
Trust-Side Data Plane
Each institution runs an isolated trust stack. trust/trust-api/trust_api/main.py polls the hub and dispatches pending work through trust/trust-api/trust_api/services/task_poller.py and task_handlers.py. It delegates cohort operations to trust/data-access-api/data_access_api/main.py, which queries local OMOP data through its cohort router/service. Imaging operations route through trust/imaging-api/imaging_api/main.py and its services, integrating local XNAT/Orthanc/PACS-facing resources. This boundary keeps clinical data and model execution local; only authorized task/results traffic crosses to the hub.
Federated-Learning Execution
The hub initiates/schedules a job, then backend FL APIs/networks coordinate server and participant clients. Two interchangeable runtimes are supported:
• NVFLARE API/server/client assets: fl-services/nvflare/fl-api-base/fl_api/app.py, fl-services/nvflare/fl-server/, fl-services/nvflare/fl-client/
• Flower API and SuperLink/SuperNode assets: fl-services/flower/fl-api-flower/fl_api/app.py, fl-services/flower/superlink/, fl-services/flower/supernode/
Reusable FL behavior is packaged as flip-utils/flip/, particularly NVFLARE controllers/components under flip-utils/flip/nvflare/. Job templates are backend-specific contracts in fl-apps/nvflare/ and fl-apps/flower/; tutorials are executable examples, not platform control-plane code.
Deployment, Infrastructure, and Observability
Docker Compose supports local/dev and production topology in deploy/; XNAT uses Swarm definitions under trust/xnat/docker-compose-stack.yml. AWS Terraform provisions the central environment—including ECS, RDS, Cognito, S3, CloudFront, EFS, KMS, service discovery, and networking—anchored by deploy/providers/AWS/main.tf and deploy/providers/AWS/ecs_services.tf. Trusts can also deploy through Helm at deploy/providers/kubernetes/templates/, with outbound-only network policy. Trust observability is Grafana/Loki/Alloy configuration under trust/observability/.
Main entry points: trust_api/main.py Trust API · project_services Hub services · flip_api/main.py Central Hub API · app.py NVFLARE runtime
Components 22
Web client
- Vue SPA · User interface for administration, projects, cohorts, and training.
flip-ui/src/main.ts - Routes & API clients
flip-ui/src/router/index.ts
Central Hub
- Central Hub API · Control-plane entry point.
flip-api/src/flip_api/main.py - Authorization · Authorizes users and trust callers.
flip-api/src/flip_api/auth/access_manager.py - Domain contracts · Service boundary for platform domain operations.
flip-api/src/flip_api/domain/schemas - Hub services · Projects, trusts, models, cohorts, and lifecycle operations.
flip-api/src/flip_api/project_services - FL scheduler · Schedules federated-learning jobs.
flip-api/src/flip_api/fl_services/services/fl_scheduler_service.py - Trust task integration · Task-oriented hub-to-trust communication.
flip-api/src/flip_api/private_services/trust_tasks.py - Platform state · Users, trusts, projects, models, schedules, and audit data.
flip-api/src/flip_api/db/database.py - AWS integrations · Cognito, S3 file operations, SES, and Step Functions.
flip-api/src/flip_api/utils/cognito_helpers.py
Trust data plane
- Trust API · Isolated institutional worker that polls the hub.
trust/trust-api/trust_api/main.py - Task poller & handlers · Fetches pending work and invokes local handlers.
trust/trust-api/trust_api/services/task_poller.py - Data Access API · Runs local cohort operations against institutional data.
trust/data-access-api/data_access_api/main.py - Imaging API · Accesses local XNAT, Orthanc, and PACS-facing resources.
trust/imaging-api/imaging_api/main.py
Federated learning
- NVFLARE runtime · API, server, and participant-client runtime.
fl-services/nvflare/fl-api-base/fl_api/app.py - Flower runtime · API with SuperLink and SuperNode execution.
fl-services/flower/fl-api-flower/fl_api/app.py - Reusable FL behavior · Shared FL logic including NVFLARE controllers and components.
flip-utils/flip - FL job templates · Backend-specific job definitions.
fl-apps/nvflare
Deployment & infrastructure
- Local Compose/Swarm · Launches local development topology.
Makefile - AWS infrastructure · Provisions central ECS, RDS, identity, storage, networking, and related services.
deploy/providers/AWS/main.tf - Trust Kubernetes deploy · Trust deployment templates with outbound-only policy.
deploy/providers/kubernetes/templates - Trust observability
trust/observability
Connections 24
- Vue SPA → Routes & API clients: navigation and API calls
- Routes & API clients → Central Hub API: HTTPS API
- Central Hub API → Authorization: authorizes
- Central Hub API → Domain contracts: uses contracts
- Domain contracts → Hub services: drives operations
- Hub services → Platform state: persists state
- Hub services → FL scheduler: requests training
- Hub services → Trust task integration: creates trust work
- Hub services → AWS integrations: uses cloud services
- Trust API → Trust task integration: outbound polling/results
- Trust API → Task poller & handlers: dispatches
- Task poller & handlers → Data Access API: cohort tasks
- Task poller & handlers → Imaging API: imaging tasks
- FL scheduler → NVFLARE runtime: launches jobs
- FL scheduler → Flower runtime: launches jobs
- NVFLARE runtime → Trust API: participant execution
- Flower runtime → Trust API: participant execution
- Reusable FL behavior → NVFLARE runtime: shared components
- FL job templates → NVFLARE runtime: NVFLARE jobs
- FL job templates → Flower runtime: Flower jobs
- Local Compose/Swarm → Central Hub API: runs locally
- AWS infrastructure → Central Hub API: hosts central services
- Trust Kubernetes deploy → Trust API: deploys
- Trust observability → Trust API: collects telemetry