How tritondatacenter/sdc-ufds works
Project type and purpose
• This is a backend, middleware‐type microservice within the Triton Data Center: “SDC-UFDS” (Unified Foundational Directory Service).
• It exposes both an LDAP API (via ldapjs) and an HTTP “CAPI” shim for backwards compatibility, stores metadata in Moray (a Triton data store), and includes a replicator service to sync data across data centers.
File-structure analysis
• Top level:
• main.js, capi.js, replicator.js – entry points for the core UFDS server, the CAPI shim, and the cross-DC replicator.
• bin/ – CLI scripts for installation, filtering, reconciliation, etc.
• etc/config*.json & smf/manifests & sapi_manifests/ – deployment and service-management manifests (SmartOS SMF, Scalr API manifest templates).
• data/ – LDIF and SQL scripts for bootstrapping and schema updates.
• schema/ – UFDS schema definitions (custom Validator subclasses).
• lib/ – core business logic split into:
– lib/db/ (Moray client wrappers: add, search, modify, delete)
– lib/schema/ (schema loader/validator)
– lib/ufds-replicator/ (replicator engine)
– lib/ufds.js (core server orchestration)
• capi/ – modules implementing the HTTP CAPI endpoints: login, customers, keys, limits, metadata, fraud, etc.
• deps/haproxy/ – vendored HAProxy source (used to build a custom load-balancer).
• test/ – unit/integration tests for DB, schema, CAPI, replicator.
README insights
• UFDS sits on ldapjs + Moray.
• CAPI shim mimics the older SDC 6.5 HTTP API.
• Dynamic schema discovery: at startup UFDS auto-loads all files under ./schema.
• Development requires a running Moray instance as configured in etc/config*.json.
Be detailed
• Major modules: capi/*, lib/db, lib/ufds-replicator, schema/.
• Both synchronous flows (client → UFDS → Moray) and asynchronous ones (replicator → remote Moray).
• Where configuration (etc/config.json) and bootstrap data (data/*.ldif) fit in during startup.
• Don’t omit the HAProxy layer or the SMF/service-manifest artifacts as they’re critical to how UFDS is deployed and scaled.
• The end result should clearly map directories/modules → runtime components → external dependencies.