my-homelab-configs/docs/code-map.md

63 lines
4.3 KiB
Markdown

# Repository Code Map
Refreshed with `graphify update .` on November 2, 2026. The generated local map
is `graphify-out/graph.json`, with `graph.html` and `GRAPH_REPORT.md` alongside
it. That directory is intentionally gitignored; this guide records the useful
paths without committing generated caches.
Graphify is a navigation aid. The paths below were checked against source;
dynamic imports and shell dispatch are not a complete call graph. The refresh
reported three extracted nodes without `source_file` metadata, and community
names were derived from hubs rather than refreshed with an LLM.
| Responsibility | Entry point | Relationship to the pipeline |
| --- | --- | --- |
| CLI and API | [jeannie](../jeannie), [API server](../cmd/jeannie-server/main.go) | API allowlisted commands use the same CLI; internal tasks and recursive remote dispatch stay excluded. |
| Profile inventory | [env.sh](../lib/jeannie/env.sh), [homelab.yml](../homelab.yml) | One shared loader exports profile defaults and Terraform variables; pipeline sources it. |
| Runtime exclusion | [cluster-runtime-guard.py](../scripts/cluster-runtime-guard.py) | Host services, private K3s workloads, API listeners and VM states gate deployment/start; a shared lock serializes pipelines. |
| Identity and state | [cluster-context.py](../scripts/cluster-context.py) | Endpoint, CA and namespace UID bind each profile; guarded tools use separate scoped backends. |
| Runtime bootstrap | [cluster/main.tf](../bootstrap/cluster/main.tf) | Selects kubeadm or native K3s; the native remote bootstrap explicitly executes Bash and requires the declared hypervisor capability. |
| Scheduling estimate | [scheduling-preflight.py](../scripts/scheduling-preflight.py) | `Estimate`, `pod_requests` and `manifests_from_plan` connect planned workloads to live capacity, placement and rollout constraints. |
| Application storage | [registry-storage-reconcile.py](../scripts/registry-storage-reconcile.py) | `prepare_local`, `publish_remote` and `remote_manifest` stage, verify and preserve registry data before placement changes. |
| Native transition | [cluster-transition.py](../scripts/cluster-transition.py), [k3s-stop.sh](../scripts/k3s-stop.sh) | A private phase journal sequences retirement, offline storage copy, bootstrap, independent identity enrollment, platform and apps. |
| Layer orchestration | [pipeline.sh](../lib/jeannie/pipeline.sh) | Applies guards, discovery/adoption, bounded transport retries and readiness checks around OpenTofu and Argo operations. |
| Documentation | [render-docs](../scripts/render-docs), [templates](templates/) | README and modular guides are generated from templates; the service catalog comes from inventory. |
| Blog | [blog.php](../apps/website/blog.php), [English copy](../apps/website/lang/en.php), [Nahuatl copy](../apps/website/lang/nah.php) | The PHP page supplies the diagram and source links; language dictionaries supply narrative copy. |
## Native transition flow
```mermaid
flowchart TD
A[Review transition plan] --> B[Verify pinned laptop identity]
B --> C[Stop laptop K3s workloads and archive state]
C --> D[Stop VMs and copy verified registry offline]
D --> E[Bootstrap K3s on Orange Pi]
E --> F[Compare API identity with direct SSH reads]
F --> G[Enroll new profile identity]
G --> H[Scheduling estimate and platform apply]
H --> I[Registry placement and app delivery]
```
Failures retain the journal and original data. Resume the same transition
command after fixing the cause. Only registry data is copied; other old laptop
PVC data requires a separate restore. A Ready node proves bootstrap readiness,
not completion of every platform or application rollout.
## Documentation maintenance
Edit `README.md.tmpl` and `docs/templates/*.md.tmpl`, then run
`scripts/render-docs`. Keep architecture, deployment, app operations and AI
operations in their own guides; duplicated copies previously left contradictory
instructions in the generated documentation. Update blog text and diagram labels
together. Website source changes take effect after the normal image build and
Argo delivery path; editing PHP does not publish the live site.
Useful local navigation commands:
```sh
graphify update .
graphify explain 'cluster-transition.py'
graphify explain 'publish_remote'
graphify query 'scheduling-preflight' --budget 1200
```