# DevOS v1 Backend Architecture ## 1. Style Modular monolith with NestJS. ## 2. Suggested Structure ```text apps/api/ ├── src/ │ ├── modules/ │ │ ├── identity/ │ │ ├── workspace/ │ │ ├── resource/ │ │ ├── permission/ │ │ ├── audit/ │ │ ├── server/ │ │ ├── container/ │ │ ├── website/ │ │ ├── domain/ │ │ ├── deployment/ │ │ ├── monitoring/ │ │ ├── automation/ │ │ └── ai/ │ ├── integrations/ │ │ ├── ssh/ │ │ ├── docker/ │ │ ├── git/ │ │ ├── dns/ │ │ ├── cloud/ │ │ └── email/ │ ├── common/ │ └── main.ts ``` ## 3. Rules - Controllers handle transport only. - DTOs define input/output contracts. - Business logic belongs in application/domain services. - Provider-specific logic belongs behind adapters. - Credential access is centralized. - Mutations are auditable. - Long-running operations run asynchronously. - External calls have timeouts, retries where safe, and idempotency where possible. ## 4. Infrastructure Adapters DevOS does not reimplement: - SSH - Git - Docker - DNS - SMTP - cloud control planes It provides unified adapters over those systems. ## 5. Async Execution Use Redis-backed jobs for: - deployment - server discovery - monitoring checks - long-running SSH commands - automation execution ## 6. Observability Every operation should carry: - request ID - correlation ID - actor - workspace - resource - action - outcome