Project Mycelium
Installation
Prerequisites
- Rust and Cargo (latest stable version)
- Git
Setup
-
Clone the repository:
git clone https://git.ourworld.tf/tfgrid_research/projectmycelium cd projectmycelium -
Build the project:
cargo build -
Run the application:
cargo run
To run with a different port:
cargo run -- --port 9998
- Open your browser and navigate to
http://localhost:9999
Architecture
Project Mycelium is a Rust web app built on Actix Web.
- Backend (Rust/Actix Web):
- Routes:
src/routes/mod.rs - Controllers:
src/controllers/ - Middleware:
src/middleware/ - Config:
src/config/ - Library crate:
src/lib.rs; Binary:src/main.rs
- Routes:
- Views and Static Assets:
- Templates (Tera):
src/views/ - Frontend JS:
src/static/js/(CSP-compliant; no inline JS)
- Templates (Tera):
- API Contract:
- Responses follow a
ResponseBuilderJSON envelope. Frontend unwraps with:const result = await response.json(); const data = result.data || result; - Display rules: render "No limit" for null/undefined numeric limits; prefer server-formatted amounts.
- Responses follow a
Marketplace Overview
- Roles & Areas
- End user, Farmer, Application Provider, Service Provider dashboards:
/dashboard/{user|farmer|application-provider|service-provider}(seeDashboardControllerinsrc/controllers/dashboard.rs). - Public catalogue:
/marketplace,/products,/products/{id},/cart,/checkout.
- End user, Farmer, Application Provider, Service Provider dashboards:
- Core Concepts
- Products (apps, services, compute). Orders and cart lifecycle.
- Slices (compute resources) on the Mycelium Grid, publicly listed at
/marketplace/compute. - Credits wallet for balance, transactions, quick top-up, and auto top-up.
- Primary Flows
- Browse products:
/products, details at/products/{id}; APIs under/api/products*. - Cart & checkout:
/cart,/checkout; APIs under/api/cart*and/api/orders*. - Slice rental: forms at
/marketplace/slice/rent*; APIs include/api/products/{id}/rentand/api/marketplace/rent-slice. - Wallet & credits: dashboard page
/dashboard/wallet; APIs under/api/wallet/*(balance, transactions, instant purchase, quick top-up, auto top-up). - Settings & SSH keys:
/dashboard/settings; APIs under/api/dashboard/settings/*and/api/dashboard/ssh-keys*.
- Browse products:
Security & CSP
- Security headers (via
SecurityHeadersinsrc/middleware/mod.rs, enabled insrc/main.rs):X-Content-Type-Options: nosniffX-Frame-Options: DENYX-XSS-Protection: 1; mode=block
- CSP practice:
- No inline JavaScript in templates; all JS under
src/static/js/. - Templates (Tera) should hydrate data via JSON blocks, keeping CSP-friendly structure.
- Note: A
Content-Security-Policyresponse header is not set yet. Recommended policy (production):Adjust as needed for external assets or APIs.Content-Security-Policy: default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'; frame-ancestors 'none'
- No inline JavaScript in templates; all JS under
Authentication & Sessions
- Auth flows (
src/routes/mod.rs):- Gitea OAuth when
GITEA_CLIENT_IDis set (seesrc/config/oauth.rs). - Username/password login otherwise (
src/controllers/auth.rs).
- Gitea OAuth when
- Password hashing:
bcryptfor stored password hashes. - Sessions (
actix-session):- Cookie store with
HttpOnlyandSameSite=Lax, TTL 2h, nameproject_mycelium_session. cookie_secure=falsein dev; enabletruebehind HTTPS in production.
- Cookie store with
- JWT (
auth_tokencookie):- Set as
HttpOnly;secure=falsein dev. Enablesecure=truein production. - Dashboard and protected scopes are wrapped by
JwtAuthmiddleware.
- Set as
Repository Layout
docs/dev/— Design, guides, and methodologies- Roadmap and UX contracts:
docs/dev/design/projectmycelium-roadmap.md
- Roadmap and UX contracts:
docs/ops/— Ops notes and runbooksconfig/zinit/— Service definitions (dev/prod)scripts/— Utilities and deployment helperssrc/— Application source (routes, controllers, views, static assets)tests/frontend_ux/— UX test suite (feature-gated)user_data/— Test fixtures and persistent data used by UX tests
Documentation
Key design and UX contract documentation lives in:
docs/dev/design/projectmycelium-roadmap.md- Canonical UX contracts (e.g., SSH Keys, Settings, Auto Top-Up)
- Proven debugging methodology and marketplace-wide audit plan
Testing
UX tests are written in Rust using WebDriver clients (thirtyfour, fantoccini) and run under the ux_testing feature flag.
- Run all UX tests:
cargo test --features ux_testing -- --nocapture - Individual suites (from
Cargo.toml):public_access_ux,authentication_ux,purchase_cart_ux,credits_wallet_uxmarketplace_categories_ux,provider_dashboards_ux,settings_management_ux,ssh_key_frontend_ux
- Requirements: Ensure a compatible WebDriver (e.g., ChromeDriver/GeckoDriver) is available on PATH.
- Pattern: Tests follow a per-step runner with persistent fixtures under
user_data/for deterministic results.
Develop
see https://git.ourworld.tf/herocode/rweb_starterkit is the web starter kit
Usage
Basic Usage
Once the application is running, you can access it through your web browser at http://localhost:9999. The default configuration provides:
- Home page at
/ - About page at
/about - Contact page at
/contact - Login page at
/login - Registration page at
/register
Configuration
see https://git.ourworld.tf/herocode/rweb_starterkit is the web starter kit
Description
Languages
Rust
45%
HTML
29.4%
JavaScript
24.4%
Shell
0.5%
Makefile
0.3%
Other
0.4%