Nitro Repo Architecture Overview
Nitro Repo is split into a Rust back end (multi-crate workspace) and a Vue/Vite front end.
Crate Layout
nitro_repo/: main binary crate. Hosts HTTP server (Axum), repository dispatch, authentication, OpenAPI, metrics.crates/core: shared domain types (database entities, repository metadata, project models, security utilities).crates/storage: abstraction over storage backends (local filesystem, S3). ProvidesDynStoragetrait object used by repositories.crates/macros: derives likeDynRepositoryHandler.
Repository Abstractions
Repositorytrait: defines HTTP handling (handle_get,handle_put, etc.), metadata (id, visibility, configs).RepositoryType: factory interface handling descriptor metadata, config validation, repository instantiation from DB.- Dynamic dispatch via
DynRepositoryenum produced byDynRepositoryHandlermacro. - Config descriptors (implementing
RepositoryConfigType) supply schemars schemas, validation, defaults; registered inREPOSITORY_CONFIG_TYPES.
Repository Implementations
- Maven: hosted + proxy support (
mavenmodule). - NPM: hosted registry (
npmmodule). - Cargo: hosted registry with sparse index support (
cargomodule) exposing the Cargo publish API, sparse index files, and archive downloads. - Python / PHP (Composer): hosted-only modules introduced during current iteration, leveraging shared
RepositoryExthelpers, metadata inserts intoVersionData.extra.
HTTP Flow
repository_routerinrepo_http.rs: resolves storage/repo by path, constructsRepositoryRequest(HTTP parts, body, parsedStoragePath, authentication).- Repository-specific handler invoked via matching HTTP method.
RepoResponseconverts storage/file metadata or custom responses into Axum responses. Shared tracing instrumentation ties intoRepositoryRequestTracing.
Authentication
- Session cookies power the browser experience (
/api/user/loginmanually verifies credentials and issues a 24h session). - API tokens expose scoped automation access and authenticate via the
Authorization: Bearer <token>header. - Optional SSO support is exposed through
/api/user/sso/login. When enabled (SecuritySettings.sso), Nitro Repo expects the upstream SSO proxy to forward identity headers (X-Forwarded-Userby default) and can auto-provision users whenauto_create_usersis true. Administrators can update these settings at runtime via/api/security/sso(exposed in the Admin UI) and the values persist in theapplication_settingstable. - Docker Registry clients use the standard Bearer token flow: any write request that reaches
/v2/**without credentials is answered with aWWW-Authenticate: Bearer …challenge whoserealmpoints at/v2/tokenand whosescopereflects the concrete repository path resolved for the request. The/v2/tokenhandler (inrepository::docker::auth) inspects the incoming authentication (session, password, or long-lived API token), validates the requested repository scopes, and mints a short-lived repository token (NewRepositoryToken). The token is hashed at rest, carries its allowed actions, and is returned to the Docker client as the Bearer token that must accompany the retried request.
Data Persistence
- DB layer via
nr_core::database::entities. Projects and versions inserted/queried directly in repositories for metadata. - Configs stored in
repository_configstable; retrieved throughDBRepositoryConfig. - Repository lookup/registration handled by
NitroRepostate with in-memory caches keyed by UUID and name pair.
Front End Integration
- Vue components under
site/: repository type configs (types/<repo>/), helper views, admin panel integration. site/src/types/repository.ts: registry of repository types/config components used in UI when creating/managing repositories.
Build/Test Notes
- Rust workspace managed via Cargo;
cargo buildrequires systempkg-config+ OpenSSL headers (libssl-dev/openssl-devel). - Front end built separately with Vite (not covered in this summary).