No description
  • Rust 47.8%
  • TypeScript 45.5%
  • Shell 4.6%
  • HCL 1.3%
  • JavaScript 0.5%
  • Other 0.3%
Find a file
2026-11-15 20:05:50 -05:00
backend feat: add various new features 2026-11-10 22:42:39 -05:00
docs feat: add various new features 2026-11-10 22:42:39 -05:00
frontend feat: add various new features 2026-11-10 22:42:39 -05:00
iac scripts 2026-11-15 19:53:50 -05:00
test feat: add photos and thumbnails for resources 2026-09-12 12:38:51 -04:00
.gitignore feat: move to nextjs instead of vite 2026-09-20 21:02:27 -04:00
compose.yaml feat: move to nextjs instead of vite 2026-09-20 21:02:27 -04:00
install.sh update script to use RUSTFS 2026-11-15 20:05:50 -05:00
README.md feat: initial implementation 2026-09-07 10:55:24 -04:00

Sharenet

A federated trust coordination layer for gift-based economies, implemented as a full-stack demo. Multiple independent hubs — each with its own Rust backend, React frontend, and Postgres database — federate with each other to share Resources, Events, Plans, Offers, and more, with no central index.

The model follows docs/sharenet-concepts.md: a schema that is incapable of representing exchange (no rates, no credit, no reciprocal edges, no terms outside the Lexicon), where every record is signed and verifiable locally.


What's inside

Layer Technology
Backend Rust (Tokio, Axum, SQLx)
Frontend React + TypeScript + Vite + Tailwind + shadcn/ui
Database PostgreSQL 16
Orchestration podman-compose (also works with docker compose)

Clean Architecture

The backend is a Cargo workspace split into three crates with a strict dependency rule (outer layers depend inward, never the reverse):

backend/crates/
├── sharenet-domain            # entities, value objects, crypto (Ed25519 + SHA-256),
│                              # canonical signing, and the `Store` port (trait).
├── sharenet-application       # use cases: resources, plans, commitments, events,
│                              # loans, offers, requests, federation. Depends only
│                              # on the domain + ports.
└── sharenet-infrastructure    # adapters: Axum HTTP, Postgres (`PostgresStore`),
                               # JWT auth, the reqwest `FederationGateway`. The binary.

sharenet-infrastructure implements the Store and FederationGateway ports; the application layer never touches Axum, SQLx, or HTTP directly.


Running

Prerequisites

Start two federated hubs

podman-compose up -d --build

This launches three hubs (add more by duplicating a hubN-* block in compose.yaml):

Hub Frontend Backend Admin login
Putnam Hub http://localhost:3001 http://localhost:8081 admin / admin123
Milltown Hub http://localhost:3002 http://localhost:8082 admin / admin123
Harbor Hub http://localhost:3003 http://localhost:8083 admin / admin123

With Docker, use docker compose up -d --build instead.

Federate the hubs

Federation is a request → accept handshake, and it is always bidirectional: a hub sends a federation request, the other hub's admin accepts it, and only then are the two hubs federated with each other.

  1. Open Putnam at http://localhost:3001 and sign in as admin. Go to Federation → Request federation, enter http://hub2-backend:8080, then repeat for http://hub3-backend:8080.
  2. Open Milltown at http://localhost:3002. Under Incoming requests you will see Putnam's request — Accept it. Then request federation with http://hub3-backend:8080.
  3. Open Harbor at http://localhost:3003, accept the incoming requests from Putnam and Milltown.

Now a Search from any hub returns results from all three hubs at once, and each hub lists the other two under Federated hubs.

Demo flow

  1. Admin creates an agent user (Users → Create user).
  2. Sign in as that agent and register a resource (Resources → Register), mark it federation-visible and available.
  3. Create a Plan (ad hoc or from a Recipe), then Commit against its requirements.
  4. Record Events (consume/produce/work/handover/loss).
  5. Lend resources (Loans), publish Offers, and run the ask/answer negotiation (Requests → Reply → Proposal → Accept → Loan).
  6. Search across the federation from the other hub.

Agent capabilities (mapped to the concepts doc)

  • Resources — register (rid = H(object_key)), update, transfer with a transfer warrant, retire; visibility (private/hub/federation) and available flag.
  • Specifications & Recipes — resource/process specs (the shared vocabulary) and type-level Recipes (Steps/Rests with Inputs/Outputs).
  • Plans — ad hoc or instantiated from a Recipe; Tasks/Rests with Requirements/Expectations. Satisfaction is derived, never stored.
  • Commitments — commit a resource (own, or borrowed under a loan), partial fills, withdraw.
  • Events — consume, produce, work, handover, loss; consume decrements, produce mints, loss retires.
  • Loans — both parties sign over a unique nonce; Lexicon terms; recall; close (handover event). Sub-lending via no-sublending enforcement.
  • Offers — standing or published, with audience + expiry.
  • Asking & answering — Requests (outcome/requirements/plan), Replies (notes only), Proposals (terms from the Lexicon), Acceptances (deliver a signed Loan).
  • Federation — admin requests federation; the peer's admin accepts (or rejects) it, and federation is always bidirectional. Search fans out transitively across the whole federation graph (with cycle protection and partial-failure tolerance); remote records are fetched and verified locally (H(object_key) = rid + signature checks).

Security & demo tradeoffs

  • Server-side keys. Agents are identified by an Ed25519 public key, but for a usable demo the hub generates and stores the private key so it can sign on the authenticated agent's behalf. A production deployment would keep keys client-side and sign in the browser.
  • Password login. Passwords are hashed with Argon2; sessions use short-lived JWTs.
  • Hub-to-hub auth. Federation endpoints are currently open between peers on the private compose network. Records are still self-verifying, so a receiving hub never has to trust the sender.
  • Quantities use f64 for the demo (real deployments would use decimals).

Configuration

Backend environment variables (per hub):

Var Default Purpose
DATABASE_URL postgres://sharenet:sharenet@localhost:5432/sharenet Postgres connection
HUB_ID random UUID Stable hub identity
HUB_NAME sharenet-hub Display name
JWT_SECRET dev-secret-change-me Token signing secret
ADMIN_USERNAME / ADMIN_PASSWORD / ADMIN_DISPLAY admin / admin / Administrator Bootstrapped admin
BIND_ADDR 0.0.0.0:8080 Listen address