architecture.md
1 # AC/DC Architecture 2 3 ## Crate Structure 4 5 ``` 6 ac-dc/ 7 ├── crates/ 8 │ ├── acdc/ # Main CLI binary 9 │ ├── acdc-core/ # Core types and utilities 10 │ ├── acdc-check/ # System requirement checks 11 │ ├── acdc-install/ # Installation engine 12 │ ├── acdc-config/ # Configuration generation 13 │ ├── acdc-wizard/ # Interactive setup wizard 14 │ ├── acdc-service/ # Systemd service management 15 │ ├── acdc-monitor/ # Monitoring and metrics 16 │ ├── acdc-update/ # Self-update system 17 │ ├── acdc-tui/ # Terminal UI components 18 │ └── acdc-radicle/ # Radicle node management 19 ``` 20 21 ## Crate Dependencies 22 23 ``` 24 acdc (CLI) 25 ├── acdc-core 26 ├── acdc-check 27 ├── acdc-install 28 ├── acdc-config 29 ├── acdc-wizard 30 ├── acdc-service 31 ├── acdc-monitor 32 ├── acdc-update 33 └── acdc-tui 34 35 acdc-check → acdc-core, acdc-tui 36 acdc-install → acdc-core, acdc-tui, acdc-check 37 acdc-config → acdc-core 38 acdc-wizard → acdc-core, acdc-tui, acdc-check, acdc-config 39 acdc-service → acdc-core, acdc-tui 40 acdc-monitor → acdc-core, acdc-tui, acdc-service 41 acdc-update → acdc-core, acdc-tui 42 acdc-radicle → acdc-core, acdc-tui 43 ``` 44 45 ## Core Types 46 47 ### Node Roles 48 49 ```rust 50 pub enum NodeRole { 51 Validator, // Block production + consensus 52 Prover, // ZK proof generation 53 Client, // Transaction submission 54 } 55 ``` 56 57 ### Networks 58 59 ```rust 60 pub enum Network { 61 Mainnet, 62 Testnet, 63 Canary, 64 Dev, 65 } 66 ``` 67 68 ### Configuration 69 70 Main config stored at `~/.config/ac-dc/config.toml`: 71 72 ```toml 73 [global] 74 data_dir = "/var/lib/ac-dc" 75 log_level = "info" 76 77 [[nodes.instances]] 78 id = "validator-1" 79 role = "validator" 80 network = "mainnet" 81 enabled = true 82 83 [nodes.instances.ports] 84 p2p_alpha = 30303 85 p2p_delta = 30304 86 rest_alpha = 3030 87 rest_delta = 4030 88 ``` 89 90 ## Data Flow 91 92 1. **Check** → Verify system meets requirements for role 93 2. **Setup** → Interactive wizard collects configuration 94 3. **Install** → Download/build binaries, install prerequisites 95 4. **Configure** → Generate config files, systemd units 96 5. **Start** → Enable and start systemd services 97 6. **Monitor** → Collect metrics, expose Prometheus endpoint 98 99 ## Service Management 100 101 Each node instance runs as a systemd service: 102 103 - Service name: `ac-dc-{node_id}.service` 104 - Config: `/etc/ac-dc/{node_id}/config.toml` 105 - Data: `/var/lib/ac-dc/{node_id}/` 106 - Logs: journald (`journalctl -u ac-dc-{node_id}`) 107 108 ## Monitoring Architecture 109 110 ``` 111 ┌─────────────┐ ┌──────────────┐ ┌──────────────┐ 112 │ ac-dc CLI │────▶│ acdc-monitor │────▶│ Prometheus │ 113 └─────────────┘ └──────────────┘ └──────────────┘ 114 │ │ 115 ▼ ▼ 116 ┌──────────────┐ ┌──────────────┐ 117 │ Alerts │ │ Grafana │ 118 └──────────────┘ └──────────────┘ 119 ``` 120 121 Metrics collected: 122 - Block height, peer count, sync progress 123 - CPU, memory, disk usage 124 - Network I/O statistics 125 - Service uptime 126 127 ## Future Phases 128 129 - **Phase 6**: Backup & Recovery (acdc-backup) 130 - **Phase 7**: Fleet Management (acdc-fleet) 131 - **Phase 8**: Network Tools (acdc-network) 132 - **Phase 9**: Explorer Profile (acdc-explorer) 133 - **Phase 10**: Attestation Service Gateway (acdc-asg) 134 - **Phase 11**: Diagnostics (acdc-diag)