Reposilite Documentation

repository·main·Indexed 23 days ago

https://github.com/dzikoysk/reposilite

A backend system written in Kotlin using Javalin, designed with Hexagonal Architecture and Domain Driven Development. It supports various infrastructure targets like SQL databases and AWS S3 storage. The project includes a frontend, a site implementation using Next.js, and a plugin system with core plugins such as swagger-plugin and javadoc-plugin. Documentation covers deployment via Docker Compose, plugin development using lifecycle events, and storage API abstractions like Location and FileDetails.

Tokens
31.1K
Snippets
73
Records
173
Agent score
82%

What's inside Reposilite

  1. Overview of Reposilite 3.x source components

    main

    Reposilite 3.x is composed of several key modules and external dependencies. If you are looking to contribute or understand the architecture, note the following primary components:

    Main Reposilite Repository

    • Backend: The core logic of Reposilite.
    • Frontend: The dashboard implementation, built using Vue 3.
    • Plugins: Official extensions for the Reposilite platform.
    • Website: The source for reposilite.com, built with Next.js (React).

    Supporting Libraries (Reposilite Playground)

    Reposilite utilizes several utility libraries from the reposilite-playground organization, including:

    • Javalin RFCs: Extension methods and coroutine support for the Javalin web framework.
    • Javalin OpenApi: Annotation-based OpenAPI implementation supporting Swagger and ReDoc.
    • Journalist: A logging abstraction supporting SL4J.
    • Exposed Upsert: Adds upsert functionality to the Exposed framework.

    Core Dependencies

    • Javalin: The underlying web framework.
    • CDN: A configuration library used to handle the .cdn format.
    • Expressible: A dependency-free utility library for enhanced response handling in functional codebases.
  2. Available Reposilite Core Plugins

    main

    Reposilite provides several basic plugins maintained alongside the core project to extend its functionality. These include:

    • example-plugin: A basic template for creating Reposilite plugins using Java and Gradle KTS.
    • groovy-plugin: Enables the scripting API in Groovy, useful for rapid prototyping of scripts.
    • javadoc-plugin: Serves -javadoc.jar files as Java documentation pages, accessible at /javadoc/<gav>.
    • migration-plugin: Facilitates upgrading from Reposilite 2.x by converting the old tokens.dat file into the JSON schema used in Reposilite 3.x.
    • swagger-plugin: Exposes a Swagger UI at the /swagger path for the built-in OpenAPI /openapi endpoint.
  3. Manage shared configuration in Reposilite

    main

    Shared configuration defines content that is consistent across all Reposilite instances, such as repositories and frontend customization.

    By default, Reposilite stores shared configuration in a database and synchronizes state between instances every 10 seconds using an interval-based approach. This supports hot-reloading of properties.

    To modify shared configuration via the web interface:

    1. Log in to the dashboard with an access token that has management permission.
    2. Navigate to the Settings tab.
  4. Why Reposilite 3.x uses Kotlin instead of Java

    main

    Reposilite 3.x transitioned from Java (used in 1.x and 2.x) to Kotlin to improve the codebase in several ways:

    • Consistency: Main sources, tests, and build scripts are fully written in Kotlin, eliminating the need for Groovy.
    • Extensibility: By using Kotlin extension functions instead of static utility methods, the project can extend base objects (like those in the Javalin framework) more cleanly.
    • Null Safety: Kotlin's language-level support for nullability allows for replacing Optional types with nullable types, reducing complexity.
    • Functional Programming: Kotlin provides better syntax and standard library support for functional programming patterns.
    • Modern Language Features: Improved generic type implementation and more robust standard library features compared to older JDK versions.
  5. Configure storage providers and mirrors for repositories

    main

    Each repository can be configured with its own specific backend settings:

    • Storage Providers: You can assign different storage backends to different repositories. For example, one repository might use the local filesystem while another uses S3-compatible object storage.
    • Mirrors: Reposilite can be configured to mirror (proxy) other external repositories. See the Mirrors Guide for detailed configuration instructions.
  6. Configure repository visibility and access

    main

    Repositories in Reposilite can have different visibility settings that control how they appear in the dashboard and how they are accessed:

    • HIDDEN: The repository will not be visible in the Reposilite dashboard. However, artifacts can still be downloaded (e.g., via Gradle). To see a HIDDEN repository in the dashboard, you must use a valid access token.
    • PRIVATE: Interaction with the repository (downloading, indexing, or deploying) is restricted. You must use a valid access token to interact with PRIVATE repositories.
  7. Understand Reposilite configuration layers

    main

    Reposilite uses three distinct configuration layers to manage different types of settings:

    1. Parameters: Startup configuration passed via program arguments (CLI flags).
    2. Local configuration: Immutable, file-based configuration for a specific instance (e.g., hostname, port, database connection). It is stored in CDN format.
    3. Settings (Shared configuration): Mutable state stored in a database that is shared across all Reposilite instances and supports hot-reloading.

    Note: Reposilite will automatically generate configuration files during the first startup if it has write permissions to the disk.

  8. Handle null safety in Kotlin

    main

    Instead of using Optional<T> wrappers like in Java, Kotlin uses nullable types marked with a ?.

    • Nullable Type: String? can hold a null value.
    • Safe Call Operator (?.): Calls a method only if the receiver is not null; otherwise returns null.
    • Elvis Operator (?:): Returns a default value if the preceding expression is null.
    val value: String? = "text"
    
    // Safe call and default value
    val isEmpty = value
      ?.isEmpty() // returns null if value is null
      ?: true     // returns true if previous expression was null

    When working with collections like Maps, accessing a missing key returns a nullable type:

    val map = mapOf("key1" to "value1")
    
    // handled is String?
    val handled: String? = map["key1"]
    
    // value is String (non-nullable) due to Elvis operator
    val value: String = map["key2"] ?: "default"
  9. Configure Reposilite configuration modes

    main

    Configuration modes determine how Reposilite handles the local configuration file using the CDN library. This is useful for managing updates when new properties are introduced.

    ModeDescription
    autoAutomatically processes and updates the configuration file if entries are missing.
    noneDisables automatic updates; users must update files manually when new properties are introduced.
  10. Configure Mirror properties

    main

    Each proxied repository has individual settings to control how it interacts with the upstream source:

    • Link: Specifies the source. Can be a URL (e.g., https://repo.maven.apache.org/maven2/) or a Local ID of another local repository (e.g., releases).
    • Store: Determines if proxied artifacts are stored locally. Enabling this improves response time and availability at the cost of disk space.
    • Storage policy: Controls how metadata is handled. This is a repository-wide setting.
      • PRIORITIZE_UPSTREAM_METADATA (Default): Attempts to fetch the latest version from the remote repository.
      • STRICT: Prioritizes the cached version over upstream metadata (effectively full offline mode).
    • Allowed groups: A list of group IDs (e.g., org.reposilite) that are permitted to be proxied. If empty, all groups are allowed.
    • Allowed extensions: Limits proxied artifacts to specific file extensions. Default allowed extensions include .jar, .war, .aar, .xml, .pom, .module, .asc, .md5, .sha1, .sha256, and .sha512.