- Rust 47.8%
- TypeScript 45.5%
- Shell 4.6%
- HCL 1.3%
- JavaScript 0.5%
- Other 0.3%
| backend | ||
| docs | ||
| frontend | ||
| iac | ||
| test | ||
| .gitignore | ||
| compose.yaml | ||
| install.sh | ||
| README.md | ||
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
- podman + podman-compose (or Docker + Docker Compose)
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.
- Open Putnam at http://localhost:3001 and sign in as
admin. Go to Federation → Request federation, enterhttp://hub2-backend:8080, then repeat forhttp://hub3-backend:8080. - 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. - 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
- Admin creates an agent user (Users → Create user).
- Sign in as that agent and register a resource (Resources → Register), mark it
federation-visible and available. - Create a Plan (ad hoc or from a Recipe), then Commit against its requirements.
- Record Events (consume/produce/work/handover/loss).
- Lend resources (Loans), publish Offers, and run the ask/answer negotiation (Requests → Reply → Proposal → Accept → Loan).
- Search across the federation from the other hub.
Agent capabilities (mapped to the concepts doc)
- Resources — register (rid =
H(object_key)), update, transfer with atransferwarrant, retire; visibility (private/hub/federation) andavailableflag. - 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-sublendingenforcement. - 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
f64for 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 |