Complete implementation details for the Remote Template Registry feature for StarForge.
Centralized template marketplace similar to npm or crates.io enabling:
- Global template sharing
- Versioning and dependency management
- Community contributions
- User authentication and publishing
- Template rating/review system
- Web interface for browsing
- Location:
src/commands/registry.rs,src/utils/registry.rs - HTTP client using
ureq(synchronous) - JWT token authentication
- Config storage in
~/.starforge/registry.toml
- Location:
registry-api/ - REST API with authentication
- In-memory stores (MongoDB ready)
- Template storage as ZIP archives
- Review/rating system
- Web UI for browsing
- Users: email, username, password hash, metadata
- Templates: name, version, description, tags, ratings, download URL
- Reviews: template ID, user ID, rating (1-5), comment
registry-api/
├── src/
│ ├── index.ts # Express app
│ ├── routes/
│ │ ├── auth.ts # Auth endpoints
│ │ ├── templates.ts # Template endpoints
│ │ └── reviews.ts # Review endpoints
│ ├── models/
│ │ ├── User.ts
│ │ ├── Template.ts
│ │ └── Review.ts
│ ├── middleware/
│ │ ├── auth.ts # JWT verification
│ │ └── errorHandler.ts
│ ├── utils/
│ │ └── logger.ts
│ └── tests/
│ └── api.test.ts
├── public/
│ └── index.html # Web UI
├── package.json
├── tsconfig.json
├── Dockerfile
└── docker-compose.yml
- Full-text search on name, description, tags
- Filter by verified status, quality score, tags
- Pagination support (limit, offset)
- Relevance-based ranking
- Semantic versioning support
- CLI version compatibility checks
- Multiple versions of same template
- Latest version resolution
- Signup/login with email and password
- JWT token-based auth
- Bcrypt password hashing (10 rounds)
- Token expiration (7 days default)
- Authenticated upload via ZIP
- Metadata validation
- Version management
- Publisher tracking
- 1-5 star ratings
- User comments
- Average rating calculation
- Rating distribution tracking
- Template browsing with search
- Login/signup forms
- Template details
- Rating display
Commands:
registry search <query>- Search remoteregistry login- Authenticateregistry publish <path>- Publish templateregistry install <name>- Download from remoteregistry review <name>- Rate templateregistry status- Show login statusregistry config --url <url>- Configure endpoint
POST /api/auth/signup
Request: { email, username, password }
Response: { success, token, username }POST /api/auth/login
Request: { email, password }
Response: { success, token, username }POST /api/auth/verify
Headers: Authorization: Bearer <token>
Response: { success, user }
POST /api/templates/search
Request: { query, tags[], verified?, min_quality?, limit, offset }
Response: { success, results[], total, limit, offset }GET /api/templates/:name/:version
Response: {
id, name, version, description, author, tags,
license, repository, homepage, documentation,
downloads, verified, ratings, download_url
}POST /api/templates/publish (auth required)
Request: {
name, version, description, author, tags,
license, repository, homepage, documentation,
content (base64)
}
Response: { success, message, template_id, url }GET /api/templates/:name/:version/download
Response: [binary zip file]
GET /api/reviews/template/:templateId
Response: { success, reviews[], total }POST /api/reviews/template/:templateId/reviews (auth required)
Request: { rating (1-5), comment? }
Response: { success, message }-
User runs:
starforge registry login- Prompts for email/password
- Sends to
/api/auth/login - Stores JWT token in
~/.starforge/registry.toml
-
User runs:
starforge registry publish --name my-template ...- Creates ZIP archive of template
- Base64 encodes ZIP
- Sends to
/api/templates/publishwith auth token - Server stores template and metadata
-
Template appears in search results
-
User runs:
starforge registry search "counter"- CLI calls
/api/templates/search - Server returns matching templates
- CLI displays results with ratings, downloads
- CLI calls
-
User runs:
starforge registry install simple-counter- CLI calls
/api/templates/simple-counter/latest - Server returns download URL
- CLI downloads ZIP from
/api/templates/.../download - CLI extracts and installs locally
- Download count incremented
- CLI calls
- Default:
https://registry.starforge.dev - Override:
export STARFORGE_TEMPLATE_REGISTRY_URL=http://localhost:3000 - CLI command:
starforge registry config --url http://localhost:3000
File: ~/.starforge/registry.toml
[registry]
url = "https://registry.starforge.dev"
token = "eyJ..."
username = "alice"
email = "alice@example.com"| Variable | Description | Default |
|---|---|---|
| PORT | API server port | 3000 |
| NODE_ENV | development/production | development |
| JWT_SECRET | Secret for signing tokens | secret |
| JWT_EXPIRATION | Token expiration | 7d |
| MONGODB_URI | MongoDB connection | localhost:27017 |
| STORAGE_DIR | Template storage directory | ./storage/templates |
| MAX_FILE_SIZE | Max upload size | 50MB |
| CORS_ORIGIN | CORS allowed origins | * |
cd registry-api
npm install
npm run devdocker-compose upRuns API + MongoDB
npm run build
NODE_ENV=production npm startWith Docker:
docker build -t starforge-registry:latest .
docker run -d -p 3000:3000 \
-e NODE_ENV=production \
-e JWT_SECRET=<random> \
-e MONGODB_URI=<production-db> \
starforge-registry:latest- Hashed with bcrypt (10 rounds, ~100ms per hash)
- Never stored in plaintext
- Always use HTTPS in production
- JWT with expiration (7 days default)
- Stored locally in config file
- Transmitted in Authorization header:
Bearer <token>
- Limited to 50MB (configurable)
- Stored as ZIP archives
- Validated before storage
- Served from
/storage/templates/directory
- All inputs validated before processing
- Email format validation
- Username uniqueness check
- Password strength requirements
- Template metadata validation
- 5 signups/hour per IP
- 10 login attempts/15min per IP
- 100 searches/hour per IP
templates::extract_zip_archive (used by both registry install and local
.zip template sources — see src/utils/templates.rs)
treats every downloaded archive as untrusted before any of its contents
touch disk. The whole archive is rejected — no partial extraction — if any
entry:
- uses an absolute path (e.g.
/etc/passwd) or a..parent-traversal component that would resolve outside the archive root, - is a symlink (detected via the entry's Unix mode bits), or
- would still resolve outside the destination directory after joining, as a final defense-in-depth check (zip-slip).
A malicious or corrupted archive — from a compromised registry, a
tampered download, or a hostile third-party .zip template — therefore
fails extraction cleanly with a descriptive error instead of silently
dropping the dangerous entries or writing files outside the intended
install location.
{
_id: ObjectId,
email: String (unique, indexed),
username: String (unique, indexed),
passwordHash: String,
createdAt: Date,
updatedAt: Date,
verified: Boolean
}{
_id: ObjectId,
name: String (indexed),
version: String,
description: String,
author: String,
tags: [String],
license: String,
repository: String,
homepage: String,
documentation: String,
downloads: Number,
verified: Boolean,
publisherId: ObjectId,
createdAt: Date,
updatedAt: Date,
ratings: {
average: Number,
count: Number,
distribution: { 1: N, 2: N, 3: N, 4: N, 5: N }
},
downloadUrl: String,
storageKey: String
}{
_id: ObjectId,
templateId: ObjectId,
userId: ObjectId,
rating: Number (1-5),
comment: String,
createdAt: Date,
updatedAt: Date
}npm testSee QUICK_START.md for curl examples
Simulate high concurrency with templates, searches, and downloads
- INFO: User actions, API calls
- WARN: Potential issues
- ERROR: Failures, exceptions
- DEBUG: Development troubleshooting
- Signups/logins per day
- Templates published per day
- Search queries per day
- Template downloads per day
- Average response time
- Error rate
- Storage usage
- Template categories/subcategories
- Featured/trending templates
- Template recommendations
- Dependency graph visualization
- User profiles/portfolios
- Template discussions
- Community moderation
- Badge system
- Analytics dashboard
- Performance metrics
- Usage insights
- Private registry instances
- Organization accounts
- Access control lists
- Audit logging
- Issues: https://github.com/Nanle-code/StarForge/issues
- Discussions: https://github.com/Nanle-code/StarForge/discussions
- Contributing: See CONTRIBUTING.md