betterNAS/docs/repository-root/skeleton.md
2026-04-01 23:39:43 -04:00

8.2 KiB

betterNAS Skeleton

This is the root build skeleton for the monorepo.

Its job is simple:

  • lock the repo shape
  • lock the language per runtime
  • lock the first shared contract surface
  • keep the self-hosted stack clear
  • make later scoped execution runs easier

Repo shape

betterNAS/
├── apps/
│   ├── web/                 # Next.js web control plane
│   ├── control-plane/       # Go control-server
│   ├── node-agent/          # Go node-service and WebDAV runtime
│   └── nextcloud-app/       # optional Nextcloud adapter
├── packages/
│   ├── contracts/           # canonical OpenAPI, schemas, TS types
│   ├── ui/                  # shared React UI
│   ├── eslint-config/       # shared lint config
│   └── typescript-config/   # shared TS config
├── infra/
│   └── docker/              # self-hosted stack for local proof
├── docs/                    # architecture and build docs
├── scripts/                 # bootstrap, verify, and stack helpers
├── go.work                  # Go workspace
├── turbo.json               # Turborepo task graph
└── skeleton.md              # this file

Runtime and language choices

Part Language Why
apps/web TypeScript + Next.js fastest way to build the control-plane UI
apps/control-plane Go strong backend baseline, static binaries, simple self-hosting
apps/node-agent Go best fit for NAS runtime, WebDAV serving, and future Nix deployment
apps/nextcloud-app PHP native language for an optional Nextcloud adapter
packages/contracts OpenAPI + JSON Schema + TypeScript language-neutral source of truth with practical frontend ergonomics

Default deployment model

The default product story is self-hosted:

                  self-hosted betterNAS stack on user's NAS

               +--------------------------------------------+
               | web control plane                          |
               | user opens this in browser                 |
               +-------------------+------------------------+
                                   |
                                   v
               +--------------------------------------------+
               | control-server                             |
               | auth / nodes / exports / grants            |
               | mount profile issuance                     |
               +-------------------+------------------------+
                                   |
                                   v
               +--------------------------------------------+
               | node-service                               |
               | WebDAV export runtime                      |
               | real NAS files                             |
               +--------------------------------------------+

 user Mac
   |
   +--> browser -> web control plane
   |
   +--> Finder -> issued WebDAV mount URL

Optional later shape:

  • hosted control-server
  • hosted web control plane
  • optional Nextcloud adapter for cloud/mobile/share surfaces

Those are not required for the core betterNAS product loop.

Canonical contract rule

The source of truth for shared interfaces is:

  1. docs/architecture.md
  2. packages/contracts/openapi/betternas.v1.yaml
  3. packages/contracts/schemas
  4. packages/contracts/src

Agents must not invent shared request or response shapes outside those locations.

Implementation lanes

                   shared write surface
      +-------------------------------------------+
      | docs/architecture.md                      |
      | packages/contracts/                       |
      +----------------+--------------------------+
                       |
       +---------------+----------------+----------------+
       |                                |                |
       v                                v                v
  node-service                    control-server   web control plane

                      optional later:
                           nextcloud adapter

Allowed ownership:

  • node-service lane
    • apps/node-agent
    • future infra/nix host module work
  • control-server lane
    • apps/control-plane
  • web control plane lane
    • apps/web
  • optional adapter lane
    • apps/nextcloud-app
  • shared contract lane
    • packages/contracts
    • docs/architecture.md

The first verification loop

[node-service]
  serves WebDAV export
        |
        v
[control-server]
  registers node + export
  issues mount profile
        |
        v
[web control plane]
  shows export and mount action
        |
        v
[local device]
  mounts in Finder

This is the main product loop.

Upstream references to steal from

Monorepo and web

Go control-server

Node-service and WebDAV

Local mount UX

Optional cloud adapter

What we steal vs what we own

Steal

  • Turborepo repo shape and task graph
  • Next.js web-app conventions
  • Go stdlib and proven Go infra libraries
  • Go WebDAV implementation
  • Finder native WebDAV mount UX
  • optional Nextcloud adapter primitives later

Own

  • the betterNAS domain model
  • the control-server API
  • the node registration and export model
  • the mount profile model
  • the self-hosted stack wiring
  • the repo contract and shared schemas
  • the root pnpm verify loop

The next implementation slices

  1. make apps/web expose the real mount flow to a user
  2. add durable control-server storage for nodes, exports, and grants
  3. define the self-hosted NAS install shape for apps/node-agent
  4. keep the optional cloud adapter out of the critical path