Skip to content

ku9nov/faynoSync

Repository files navigation

FaynoSync

a-github-banner-for-faynosync-featuring

Documentation Docker Pulls GitHub Release Docker Compose Test


πŸ“– Overview

faynoSync is a self-hosted, open-source API server for managing and updating cross-platform desktop applications (Windows, macOS, Linux). It enables automatic and on-demand updates for client software, making it easy to deliver new versions to users through a customizable update workflow.

The server allows developers to upload application builds to S3, set version metadata, and expose a simple REST API for clients to check for updates. When a client queries the API, it receives version information and a download URL if an update is available.

faynoSync supports both background updates and manual update prompts, depending on how the client integrates with the API. This gives developers full control over how and when updates are delivered to end-users.

It’s ideal for managing updates in Electron apps, native desktop applications, or any cross-platform software where you want full control over versioning, distribution, and update channels (e.g. stable, beta, nightly).


πŸ› οΈ Supported Technologies

Category Technology Description
API Framework Go (Golang) Main application server built with Go
Database MongoDB Primary database for storing application metadata, users, and configurations
Cache & Performance Redis Used for performance mode and statistics caching
Storage S3-Compatible Supports multiple cloud storage providers:
AWS S3 Amazon Web Services Simple Storage Service
MinIO Self-hosted S3-compatible object storage
Google Cloud Storage Google Cloud Platform storage service
DigitalOcean Spaces DigitalOcean's S3-compatible object storage

πŸ“– Documentation Links


πŸ–₯️ Frontend Links


πŸ“± Client Application Examples

You can find examples of client applications here.

πŸ”— Example Links

πŸ“‹ API Usage Template


πŸš€ Installation

To use this application, you will need to have Golang installed on your machine. You can install it from the official website.

πŸ“₯ Installation Steps

  1. Install Go: Download and install from golang.org

  2. Clone Repository: Once you have installed Golang, clone this repository to your local machine:

git clone https://github.com/ku9nov/faynoSync.git

βš™οΈ Configuration

To configure the faynoSync, you will need to set the following environment variables:

πŸ”§ Required Environment Variables

# Storage Configuration
STORAGE_DRIVER (`minio`, `aws`, `gcp` or `digitalocean`)
S3_ACCESS_KEY (Your AWS or Minio access key ID.)
S3_SECRET_KEY (Your AWS or Minio secret access key.)
S3_REGION (The AWS region in which your S3 bucket is located. For Minio this value should be empty.)
S3_BUCKET_NAME_PRIVATE (The name of your private S3 bucket.)
S3_ENDPOINT_PRIVATE (s3 endpoint, check documentation of your cloud provider)
S3_BUCKET_NAME (The name of your public S3 bucket. Artifacts will be uploaded here by default.)
S3_ENDPOINT (The public bucket endpoint for S3. Check the documentation of your cloud provider. Artifacts will be uploaded here by default.)

# Server Configuration
ALLOWED_CORS (urls to allow CORS configuration)
PORT (The port on which the auto updater service will listen. Default: 9000)

# Database Configuration
MONGODB_URL=mongodb://root:MheCk6sSKB1m4xKNw5I@127.0.0.1/cb_faynosync_db?authSource=admin (see docker-compose file)

# Security Configuration
API_KEY (generated by 'openssl rand -base64 16') Used for SignUp
API_URL=(public URL to this API)

# Performance Configuration
PERFORMANCE_MODE (Set to `true` to enable performance mode)

# Redis Configuration
REDIS_HOST (The hostname for the Redis server, default: `localhost`)
REDIS_PORT (The port for the Redis server, default: `6379`)
REDIS_PASSWORD (Password for Redis, leave empty if not set)
REDIS_DB (The Redis database number to use, default: `0`)

# Feature Flags
ENABLE_PRIVATE_APP_DOWNLOADING=false (if enabled, then apps located in private S3 can be downloaded using the public API; if disabled, then download links require authentication)
ENABLE_TELEMETRY (Set to `true` to enable telemetry)

πŸ“ Environment File Setup

You can set these environment variables in a .env file in the root directory of the application. You can use the .env.local file, which contains all filled variables.


🐳 Docker Configuration

To build and run the API with all dependencies, you can use the following command:

docker compose up --build

πŸ§ͺ Running Tests

You can now run tests using this command (please wait until the s3-service successfully creates the bucket):

docker exec -it faynoSync_backend "/usr/bin/faynoSync_tests"

πŸ”§ Development Setup

If you only want to run dependency services (for local development without Docker), use this command:

docker compose -f docker-compose.yaml -f docker-compose.development.yaml up

πŸ’» Usage

To use the auto updater service, follow these steps:

πŸ”¨ Build the Application

go build -o faynoSync faynoSync.go

πŸš€ Start the Service

  1. Start with Migrations:
./faynoSync --migration
  1. Rollback Migrations (if needed):
./faynoSync --migration --rollback

πŸ“€ Upload Your Application

  1. Upload your application to S3 and set the version number in faynoSync-dashboard or using API.

πŸ” Check for Updates

  1. In your client application, make a GET request to the auto updater service API, passing the current version number as a query parameter:
http://localhost:9000/checkVersion?app_name=myapp&version=0.0.1&owner=admin

πŸ“‹ API Response

The auto updater service will return a JSON response with the following structure:

{
    "update_available": false,
    "update_url_deb": "http://localhost:9000/download?key=secondapp/myapp-0.0.1.deb",
    "update_url_rpm": "http://localhost:9000/download?key=secondapp/myapp-0.0.1.rpm"
}

If an update is available, the update_available field will be true, and the update_url field will contain a link to the updated application.

πŸ”” User Notification

  1. In your client application, show an alert to the user indicating that an update is available and provide a link to download the updated application.

πŸ§ͺ Testing

πŸš€ Run End-to-End Tests

go test

πŸ”¨ Build Test Binary

go test -c -o faynoSync_tests

πŸ“‹ Test Requirements

Test Descriptions

To successfully run the tests and have them pass, you need to populate the .env file.

The tests verify the implemented API using a test database and an existing S3 bucket.

πŸ“‹ Complete List of Tests
  • TestHealthCheck
  • TestLogin
  • TestFailedLogin (expected result from API "401")
  • TestListApps
  • TestListAppsWithInvalidToken (expected result from API "401")
  • TestAppCreate
  • TestSecondaryAppCreate (expected result from API "failed")
  • TestUploadApp
  • TestUploadDuplicateApp (expected result from API "failed")
  • TestDeleteApp
  • TestChannelCreateNightly
  • TestChannelCreateStable
  • TestUploadAppWithoutChannel (expected result from API "failed")
  • TestMultipleUploadWithChannels
  • TestSearchApp
  • TestCheckVersionLatestVersion
  • TestFetchkLatestVersionOfApp
  • TestMultipleDelete
  • TestDeleteNightlyChannel
  • TestDeleteStableChannel
  • TestPlatformCreate
  • TestUploadAppWithoutPlatform
  • TestArchCreate
  • TestUploadAppWithoutArch
  • TestDeletePlatform
  • TestDeleteArch
  • TestListArchs
  • TestListPlatforms
  • TestListChannels
  • TestListArchsWhenExist
  • TestListPlatformsWhenExist
  • TestListChannelsWhenExist
  • TestSignUp
  • TestFailedSignUp (expected result from API "401")
  • TestUpdateSpecificApp
  • TestListAppsWhenExist
  • TestDeleteAppMeta
  • TestUpdateChannel
  • TestUpdateApp
  • TestUpdatePlatform
  • TestUpdateArch
  • TestFailedUpdatePlatform (expected result from API "400")
  • TestChannelCreateWithWrongName (expected result from API "400")
  • TestCreateSecondPlatform
  • TestCreateSecondArch
  • TestMultipleUploadWithSameExtension
  • TestCheckVersionWithSameExtensionArtifactsAndDiffPlatformsArchs
  • TestMultipleDeleteWithSameExtensionArtifactsAndDiffPlatformsArchs
  • TestDeleteSecondPlatform
  • TestDeleteSecondArch
  • TestCreatePublicApp
  • TestDeletePublicAppMeta
  • TestUpdateSpecificAppWithSecondUser (expected result from API "500")
  • TestListAppsWithSecondUser
  • TestListChannelsWithSecondUser
  • TestListPlatformsWithSecondUser
  • TestListArchsWithSecondUser
  • TestUpdateAppWithSecondUser (expected result from API "500")
  • TestUpdateChannelWithSecondUser (expected result from API "500")
  • TestUpdatePlatformWithSecondUser (expected result from API "500")
  • TestUpdateArchWithSecondUser (expected result from API "500")
  • TestMultipleDeleteWithSameExtensionArtifactsAndDiffPlatformsArchsWithSecondUser (expected result from API "500")
  • TestDeleteNightlyChannelWithSecondUser (expected result from API "500")
  • TestDeletePlatformWithSecondUser (expected result from API "500")
  • TestDeleteArchWithSecondUser (expected result from API "500")
  • TestDeleteAppMetaWithSecondUser (expected result from API "500")
  • TestCreateTeamUser
  • TestTeamUserLogin
  • TestFailedUploadAppUsingTeamUser (expected result from API "403")
  • TestFailedUpdateAppUsingTeamUser (expected result from API "403")
  • TestFailedUpdateChannelUsingTeamUser (expected result from API "403")
  • TestFailedUpdatePlatformUsingTeamUser (expected result from API "403")
  • TestFailedUpdateArchUsingTeamUser (expected result from API "403")
  • TestListAppsUsingTeamUserBeforeCreate
  • TestListChannelsUsingTeamUserBeforeCreate
  • TestListPlatformsUsingTeamUserBeforeCreate
  • TestListArchsUsingTeamUserBeforeCreate
  • TestAppCreateTeamUser
  • TestListAppsUsingTeamUser
  • TestFailedDeleteTeamUserApp (expected result from API "403")
  • TestChannelCreateTeamUser
  • TestListChannelsUsingTeamUser
  • TestFailedDeleteTeamUserChannel (expected result from API "403")
  • TestPlatformCreateTeamUser
  • TestListPlatformsUsingTeamUser
  • TestFailedDeleteTeamUserPlatform (expected result from API "403")
  • TestArchCreateTeamUser
  • TestListArchsUsingTeamUser
  • TestFailedDeleteTeamUserArch (expected result from API "403")
  • TestFailedUpdateTeamUser (expected result from API "403")
  • TestUpdateTeamUser
  • TestUpdateAppUsingTeamUser
  • TestUpdateChannelUsingTeamUser
  • TestUpdatePlatformUsingTeamUser
  • TestUpdateArchUsingTeamUser
  • TestFailedAppCreateTeamUser (expected result from API "403")
  • TestDeleteTeamUserApp
  • TestDeleteTeamUserChannel
  • TestDeleteTeamUserPlatform
  • TestDeleteTeamUserArch
  • TestListTeamUsers
  • TestDeleteTeamUser
  • TestWhoAmIAdmin
  • TestWhoAmITeamUser
  • TestFailedUpdateAdminUser
  • TestUpdateAdminUser
  • TestFailedLoginWithOldPassword
  • TestSuccessfulLoginWithNewPassword
  • TestFailedUpdateAdminUserUsingTeamUser
  • TestFilterSearchWithChannel
  • TestFilterSearchWithChannelAndPublished
  • TestFilterSearchWithChannelAndPublishedAndCritical
  • TestFilterSearchWithChannelAndPublishedAndCriticalAndPlatform
  • TestFilterSearchWithChannelAndPublishedAndCriticalAndPlatformAndArch
  • TestSearchOnlyPublished
  • TestSearchOnlyCritical
  • TestSearchOnlyUniversalPlatform
  • TestMultipleUploadWithIntermediate
  • TestUpdateSpecificAppWithIntermediate
  • TestCheckVersionWithIntermediate
  • TestMultipleDeleteWithIntermediate
  • TestTelemetryWithVariousParams
  • TestCreateAppWithUpdaters
  • TestPlatformCreateWindows
  • TestUpdatePlatformWindows
  • TestPlatformCreateMacos
  • TestUpdatePlatformMacos
  • TestPlatformCreateMacosSquirrel
  • TestUpdatePlatformMacosSquirrel
  • TestMultipleUploadWithUpdaters
  • TestCheckVersionWithUpdaters
  • TestSquirrelReleases (Not implemented yet)
  • TestDeletePlatformWindows
  • TestDeletePlatformMacos
  • TestDeletePlatformMacosSquirrel
  • TestDeleteAppMetaUpdaters
  • TestPlatformCreateMacosTauri
  • TestDeletePlatformMacosTauri

  • πŸ”„ Database Migrations

    πŸ“¦ Install Migration Tool

    Install migrate tool here.

    πŸ†• Create New Migrations

    cd mongod/migrations
    migrate create -ext json name_of_migration

    Then run the migrations again.

    πŸ”— Migration Tool Link


    πŸ“„ License

    This application is licensed under the Apache license. See the LICENSE file for more details.

    πŸ”— License Link

    • License File: LICENSE - Apache License 2.0