|
| 1 | +# DID-Native Drives and Domain Routing Plan |
| 2 | + |
| 3 | +## Overview |
| 4 | +Atomic Data is moving away from a fixed "main drive" at the root `/` of a server. Instead, every Drive is a first-class decentralized citizen identified by a DID, and human-readable access is handled via a **Domain-to-DID mapping** system. |
| 5 | + |
| 6 | +## Core Concepts |
| 7 | + |
| 8 | +### 1. Identity vs. Alias |
| 9 | +- **Identity (Immutable)**: A Drive is identified by its DID: `did:ad:{genesis}?drive={hash}`. |
| 10 | +- **Alias (Mutable)**: A Domain or Subdomain (e.g., `joep.atomicdata.dev`, `localhost:9883`) is an alias that routes to a specific Drive DID. |
| 11 | + |
| 12 | +### 2. Agent-First Onboarding |
| 13 | +Onboarding no longer starts with a "nameless" drive. It starts with the user: |
| 14 | +1. **Create Agent**: Generate an Ed25519 keypair (`did:ad:agent:...`). |
| 15 | +2. **Create Drive**: The Agent signs the genesis commit for a new Drive. |
| 16 | +3. **Bind Alias**: The Server maps the current `Host` (e.g., `localhost`) to this Drive's DID. |
| 17 | + |
| 18 | +### 3. Multi-Tenancy & Routing |
| 19 | +The server uses the HTTP `Host` header to determine which Drive to serve: |
| 20 | +- `joep.atomicdata.dev` -> Serves Joep's Drive. |
| 21 | +- `jane.atomicdata.dev` -> Serves Jane's Drive. |
| 22 | +- `localhost:9883` -> Serves the developer's default Drive. |
| 23 | + |
| 24 | +--- |
| 25 | + |
| 26 | +## Implementation Phases |
| 27 | + |
| 28 | +### Phase 1: Backend Routing & Mapping |
| 29 | +- [ ] **Mapping Store**: Implement a mechanism in `atomic-server` to store and query `Host -> Drive DID` mappings. |
| 30 | +- [ ] **Host-Based Resolution**: Update the HTTP request handler to check the `Host` header. |
| 31 | +- [ ] **Relative Pathing**: Ensure that paths like `/classes` are correctly resolved relative to the Drive DID mapped to the current Host. |
| 32 | + |
| 33 | +### Phase 2: Drive Lifecycle & Population |
| 34 | +- [ ] **Standard Initialization**: Refactor `atomic_lib::populate` so it can be applied to any Drive DID (creating `/classes`, `/tags`, etc. within that drive). |
| 35 | +- [ ] **Drive Resource**: Ensure the Drive resource itself contains the necessary metadata (Drive Public Key, Hash, Owner). |
| 36 | + |
| 37 | +### Phase 3: Server Setup & Onboarding UI |
| 38 | +- [ ] **Node Setup State**: Detect when a server has no mappings and enter "Setup Mode". |
| 39 | +- [ ] **Setup UI**: A dedicated frontend flow for creating an Agent and the first Drive. |
| 40 | +- [ ] **Alias Registration**: A secure way for the first Agent to "claim" the server's primary domain. |
| 41 | + |
| 42 | +### Phase 4: Decentralized Discovery |
| 43 | +- [ ] **JSON-AD Headers**: Include the true `did:ad` identity in HTTP responses so clients can switch to P2P resolution. |
| 44 | +- [ ] **DHT/Reticulum Announces**: Servers announce the Drive hashes they host to the P2P networks. |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +## Success Criteria |
| 49 | +1. Running `atomic-server` for the first time leads to an Agent/Drive creation flow. |
| 50 | +2. Multiple drives can be accessed via subdomains on the same server instance. |
| 51 | +3. Every drive has its own `/classes`, `/templates`, and `/files` collections. |
| 52 | +4. Resources shared via `did:ad` identifiers are resolvable across different servers using the routing hints. |
0 commit comments