Architecture
Suggested Stack
- Language: Go (single binary, Linux/Windows friendly, good CLI/service ecosystem).
- CLI: Cobra (or urfave/cli).
- TUI: Bubble Tea.
- Config: YAML + schema versioning.
- State store: local SQLite (or equivalent embedded DB) for non-sensitive runtime state.
- Token storage: OS keyring integration.
High-Level Components
syncddaemon- Scheduler loop
- Per-repo worker orchestration
- Event/log persistence
- Trace IDs for every sync run and repo job
- Local control API for CLI/TUI
syncctlCLI- Full config management
- Daemon control/actions
- One-shot per-repo sync actions
synctui- Dashboard for status/stats/logs
- Actions equivalent to CLI
- Core library
- Git safety engine
- Provider adapters (GitHub/Azure)
- Source/account registry (multi-account, multi-provider)
- Workspace manager (clean repo folder layout)
- Cache manager
- State persistence layer (config + local DB)
- Update manager
- Installer/service registration logic
Source and Account Model
- A
sourceis a provider account binding (for example one GitHub PAT or one Azure DevOps PAT). - Multiple sources can be active at once across providers.
- Sources support personal/private and corporate/team/organization account contexts.
- Repositories map to a specific source ID.
Workspace Layout (Managed)
Use a deterministic workspace path convention for easy navigation:
<workspace_root>/<provider>/<account_or_org>/<project_or_repo>
Validation and repair behavior:
syncctl workspace layout checkreports drift when configured repo paths do not match the deterministic managed layout.syncctl workspace layout fix --dry-runpreviews the path updates without mutating config.syncctl workspace layout fixupdates repo paths in config and can create missing managed directories when enabled.
Examples:
workspace/github/acme-org/platform-apiworkspace/github/jane-doe/dotfilesworkspace/azuredevops/contoso/erp-service
Repository Layout (Target)
text
cmd/
syncd/
syncctl/
synctui/
internal/
core/
sync/
git/
providers/
auth/
config/
cache/
daemon/
update/
install/
telemetry/
docs/
ai/
scripts/Sync Flow (Per Repo)
- Acquire repo lock.
- Inspect dirty state (staged/unstaged/untracked/conflicts).
- If dirty: log skip reason and exit.
- Fetch remote refs and prune stale refs.
- Resolve default branch (
origin/HEAD-> provider API fallback). - Compare current branch to upstream.
- Fast-forward update current branch when safe and behind.
- Ensure default branch local ref is up to date.
- Evaluate stale-branch cleanup conditions.
- If checked-out branch is stale and safe to delete:
- checkout default branch
- delete stale local branch
- Emit result event + metrics.
- Release lock.
Local Control API
Expose daemon functions to CLI/TUI via local IPC (named pipe / unix socket):
- Get daemon status
- Trigger sync all
- Trigger sync single repo
- List repositories and state
- Show/refresh cache
- Show logs/events
- Show trace details by run ID
- Reload config
Update Strategy
- Signed release manifest
- Checksum verification
- Atomic binary swap
- Rollback on failed replace
- Channels:
stable(v1), optionalbeta