IDA Stack CI/CD (ida-stack)
The IDA (Internal Diligence Agent) Stack is a multi-repository distributed system designed to monitor, ingest, decode, analyze, and visualize transactions for financial compliance and fraud detection. The system consists of 5 core repositories:
ida-deployment: Central CI/CD orchestrator, Docker Swarm / Docker Compose stack configurations, environment setups, and deployment manifests.ida-backend: TypeScript / Node.js core server for transaction feed ingestion, journal event storage (MongoDB), and detector routing.ida-detector: Python / FastAPI fraud detection engine (aml-detector) running evaluation algorithms and returning alerts to the backend.ida-source-pi: Scenario simulation driver and replay server (source-pi-replay) serving pre-recorded DEUSS runs and synthetic patterns.ida-admin: Next.js standalone web dashboard providing real-time UI monitoring of events, alerts, feeds, and detector states.
Primary Goals
- Centralized Orchestration: Using
ida-deploymentto control build dependency ordering, global versioning, and environment deployments across all 5 sub-projects. - Unified Pipeline Tagging: Assigning a single pipeline tag (
DEPLOY_TAG=$CI_PIPELINE_ID) to ensure all 4 microservices are built, tagged, and deployed in complete lockstep. - Automated Containerization & Registry Management: Building OCI-compliant container images for each microservice and publishing them to the GitLab Container Registry.
- Declarative & Safe Deployment: Deploying containerized stacks via Docker Swarm (
docker stack deploy) onto remote target hosts with automated health checks and manual approval gates for demo and production releases.
Prerequisites & Configuration
Required GitLab CI/CD Variables
| Variable Name | Scope / Target | Description |
|---|---|---|
GROUP_PATH | Orchestrator | Group path on GitLab containing all 5 repositories (e.g., bebi/ai-agents) |
DEPLOY_USER | Deployment Job | SSH user authorized to connect to target deployment host |
DEPLOY_HOST | Deployment Job | Domain name or IP of the target deployment host |
SSH_KEY | Deployment Job | Private SSH key (masked/protected) used to authenticate deployment tasks via SSH/SCP |
CI_REGISTRY | All Repositories | GitLab Container Registry endpoint |
CI_REGISTRY_USER | All Repositories | Username for GitLab Container Registry authentication |
CI_REGISTRY_PASSWORD | All Repositories | Password / Access Token for GitLab Container Registry |
IMAGE_TAG | Downstream Jobs | Dynamically passed down from ida-deployment to sub-pipelines (inherited from $DEPLOY_TAG) |
APP_ENV | ida-admin Build | Environment name passed into Next.js build-time injection (e.g., development) |
Runner Requirements
- Orchestrator Runner Tag: Dedicated runner tag for the orchestrator pipeline.
- Orchestrator Base Image: Alpine-based CI image with utility tools (
openssh-client-default,envsubst,dos2unix). - Component Build Image: Docker-in-Docker (
docker:24.0.5base image withdocker:24.0.5-dindservice) enabled for building container images. - Network Access: Runners must have outbound network access to the target host (
DEPLOY_HOST) on SSH port 22 and access to the GitLab Container Registry.
Required Developer & Administrative Permissions
- Developer Access: Permission to create branches, open Merge Requests, and trigger manual pipelines in component repositories.
- Maintainer / Owner Access: Required to trigger the
deploy-demomanual stage inida-deployment, manage CI/CD secret variables (SSH_KEY), and push directly to protected branches (master). - Target Host Access: SSH public key corresponding to
$SSH_KEYmust be placed in~/.ssh/authorized_keysforDEPLOY_USERonDEPLOY_HOST.
Repository Structure
<workspace>/
├── ida-deployment/ ← Central Orchestrator Repository
│ ├── .gitlab-ci.yml ← Master pipeline definition (setup, build triggers, deploy)
│ ├── demo/
│ │ ├── docker-compose-ida.yml ← Production/Demo Docker Swarm compose template (${DEPLOY_TAG})
│ │ ├── config/
│ │ │ └── ida-backend.jsonc ← Demo-specific backend feed & storage configuration
│ │ └── README.md ← Demo environment documentation
│ ├── demo-local/
│ │ └── docker-compose.yml ← Local checkout-based compose stack (no registry pull)
│ └── development/
│ ├── docker-compose.yml ← Local live-chain dev stack (Anvil EVM + local builds)
│ └── docker-compose.jsonreplay.yml ← Local JSON fixture replay overlay
├── ida-backend/ ← Microservice 1: Backend API & Ingest
│ └── .gitlab-ci.yml ← Container build & registry push stage
├── ida-detector/ ← Microservice 2: Python AML Detector
│ └── .gitlab-ci.yml ← Container build & registry push stage
├── ida-source-pi/ ← Microservice 3: Replay Server & Scenario Generator
│ └── .gitlab-ci.yml ← Packaging scenarios/demo-scenarios.zip & container build
└── ida-admin/ ← Microservice 4: Next.js Frontend Dashboard
└── .gitlab-ci.yml ← Next.js standalone container build
Detailed Configuration Breakdown
ida-deployment/.gitlab-ci.yml (Master Pipeline):
setupstage (generate-tag): Creates abuild.envdotenv artifact settingDEPLOY_TAG=$CI_PIPELINE_ID.buildstage (build-backend,build-detector,build-source-pi,build-admin): Uses GitLabtriggersyntax to invoke downstream pipelines in sibling repositories withstrategy: depend. PassesIMAGE_TAG=$DEPLOY_TAGto all downstream jobs.deploystage (deploy-demo): Manually triggered onmasterbranch. Copies./demodirectory toDEPLOY_HOST, substitutes${DEPLOY_TAG}insidedocker-compose-ida.ymlusingenvsubst, and triggersdocker stack deployon the host.
Component .gitlab-ci.yml files (ida-backend, ida-detector, ida-source-pi, ida-admin):
- Each repository contains a single
buildstage running Docker-in-Docker. - Authenticates to
$CI_REGISTRYviadocker login. - Tags built images with both
$IMAGE_TAG(the unique pipeline ID) andlatest. - Pushes images to the GitLab Container Registry.
demo/docker-compose-ida.yml (Target Deployment Manifest):
- Configures the 5 container services:
mongo,ida-backend,ida-detector,source-pi-replay,ida-admin. - References images dynamically using
${DEPLOY_TAG}. - Sets healthcheck probes (
mongosh,fetch,urllib.request) for every service. - Configures container networking and port mappings (
8090,8091,9100,3010).
Environments & Deployment
| Environment | Host / Location | Image Source | Primary Purpose | Approval Mechanism |
|---|---|---|---|---|
Development (development/) | Local Developer Machine | Local docker compose build | Full feature development with live in-memory Anvil EVM chain simulator | None |
Demo Local (demo-local/) | Local Developer Machine | Local docker compose build | Chain-free local testing of replay scenario feeds and UI | None |
Demo / Pilot (demo/) | Remote pilot host | GitLab Container Registry (:${DEPLOY_TAG}) | Chain-free public pilot demonstration running recorded scenario replays | Manual Gate: Required trigger on deploy-demo in ida-deployment master branch |
| Testnet | Remote Target Host | GitLab Container Registry | Multi-node testnet integration testing | TBD |
| Production | Production Cluster | GitLab Container Registry | Production rollout | TBD |
Approval Mechanisms & Deployment Gates
- Pipeline Synchronization Gate (
strategy: depend): The orchestrator pipeline forces all 4 downstream component build pipelines to complete successfully before allowing the deployment stage to unlock. - Branch Protection & Manual Execution: Deployment to the
demoenvironment is restricted to commits on themasterbranch ofida-deploymentand requires an explicit Manual Action (when: manual) executed by an authorized maintainer.
CI/CD Workflow
Pipeline Variants & Execution Triggers
-
Orchestrated Master Release Pipeline:
- Trigger: Commit or Merge Request merge into
masterbranch ofida-deployment. - Flow:
generate-tag→ Parallel downstream builds → Manualdeploy-demogate → Swarm Deployment.
- Trigger: Commit or Merge Request merge into
-
Component Repository Pipelines:
- Trigger: Direct commit or merge inside
ida-backend,ida-detector,ida-source-pi, orida-admin. - Flow: Builds container image tagged with commit/pipeline tag and
:latestfor feature branch testing or standalone verification.
- Trigger: Direct commit or merge inside
-
Bugfix & Feature Branch Pipelines:
- Developers create feature branches (e.g.
fix/detector-scoring). Downstream builds can be tested independently without altering the publisheddemostack tag until merged intomaster.
- Developers create feature branches (e.g.
How to Use the System
Standard Developer Tasks
Running the Full Live Stack Locally
cd ida-deployment/development
docker compose up -d --build
# Access Admin GUI at http://localhost:3000
Working on a Single Microservice (e.g. ida-backend)
- Create a feature branch in
ida-backend(e.g.,feature/new-feed-parser). - Test locally using
demo-localordevelopmentcompose stacks. - Commit and push your feature branch. The
ida-backend.gitlab-ci.ymlwill automatically build and publish a test container image. - Create a Merge Request to
masterinida-backend.
Updating Scenario Recordings or Fixtures
- Add or modify scenario JSON files in
ida-source-pi/scenarios/. - Package updated recordings into
scenarios/demo-scenarios.zip. - Commit changes to
ida-source-pi. When merged, the next orchestrator run will bake the new zip into theida-source-piimage.
Administrative & Release Tasks
Triggering a Deployment to the Demo Environment
- Ensure all component code changes are merged into their respective
masterbranches. - Navigate to
ida-deploymentin GitLab and push to or merge intomasterbranch. - Monitor the
setupandbuildstages — confirmbuild-backend,build-detector,build-source-pi, andbuild-adminjobs pass. - In the GitLab CI UI, click on the
deploy-demoaction in thedeploystage and click Play (Run). - Check the pipeline logs to verify SCP transfer,
envsubstexpansion, and successful execution ofdocker stack deploy.
Inspecting the Live Demo Stack on the Target Server
ssh deploy@<your-pilot-host>
docker stack ps ida-demo
docker service logs -f ida-demo_ida-backend
Troubleshooting & Rollbacks
Common Pipeline Failures & Resolutions
| Failure Symptom | Cause | Resolution |
|---|---|---|
build-* downstream trigger job fails | Compilation or test failure in component repository | Click into the child pipeline link in GitLab UI to inspect component build logs. Fix error in component repo and retry. |
deploy-demo fails with Permission denied (publickey) | SSH key mismatch or missing $SSH_KEY variable | Ensure SSH_KEY is present in ida-deployment CI/CD variables and that the public key is registered in ~/.ssh/authorized_keys for DEPLOY_USER on DEPLOY_HOST. |
docker stack deploy image pull error on host | Docker host cannot authenticate to GitLab Registry | Verify $DEPLOY_USER on host has run docker login <registry-domain> or ensure --with-registry-auth flag is supplied. |
Container stuck in starting / unhealthy state | Container health check failing after startup | Check service logs on host: docker service logs ida-demo_<service-name>. Verify MongoDB ping response or HTTP health check endpoints. |
Rollback Procedures
Method 1: GitLab CI One-Click Pipeline Rollback
- Open the
ida-deploymentrepository in GitLab and go to CI/CD → Pipelines. - Locate the last known working pipeline on
master(note its Pipeline ID, e.g.78451). - Click on the pipeline details to open the stage view.
- Locate the
deploy-demojob in thedeploystage of that historical pipeline. - Click Retry / Play — the orchestrator will re-run the deployment using
DEPLOY_TAG=78451, instantly deploying the previously verified container images.
Method 2: Manual Emergency Command-Line Rollback
ssh deploy@<your-pilot-host>
# Identify the previously working pipeline ID
docker image ls | grep ida-backend
# Deploy with the known-good tag
cd ./ida-deployment
export DEPLOY_TAG=78451
cat ./demo/docker-compose-ida.yml | envsubst | docker stack deploy --prune --with-registry-auth --compose-file - ida-demo
# Verify rollback state
docker stack ps ida-demo