{"id":23414198,"url":"https://github.com/unmade/shelf-back","last_synced_at":"2025-04-12T05:44:47.745Z","repository":{"id":39619030,"uuid":"326400017","full_name":"unmade/shelf-back","owner":"unmade","description":"Shelf App Backend - self-hosted file storage","archived":false,"fork":false,"pushed_at":"2024-03-04T18:13:54.000Z","size":2817,"stargazers_count":26,"open_issues_count":7,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T05:44:33.778Z","etag":null,"topics":["arq","edgedb","fastapi","python3"],"latest_commit_sha":null,"homepage":"https://getshelf.cloud","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/unmade.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-01-03T12:18:19.000Z","updated_at":"2024-02-21T01:04:47.000Z","dependencies_parsed_at":"2023-12-15T14:46:46.507Z","dependency_job_id":"e678e405-f5a9-44f5-bfc2-85f71802bf0a","html_url":"https://github.com/unmade/shelf-back","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unmade%2Fshelf-back","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unmade%2Fshelf-back/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unmade%2Fshelf-back/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unmade%2Fshelf-back/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unmade","download_url":"https://codeload.github.com/unmade/shelf-back/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248525155,"owners_count":21118616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arq","edgedb","fastapi","python3"],"created_at":"2024-12-22T19:57:24.832Z","updated_at":"2025-04-12T05:44:47.719Z","avatar_url":"https://github.com/unmade.png","language":"Python","readme":"# Shelf App\n\n[![build](https://github.com/unmade/shelf-back/workflows/Test/badge.svg)](https://github.com/unmade/shelf-back/blob/master/.github/workflows/tests.yml)\n[![codecov](https://codecov.io/gh/unmade/shelf-back/branch/master/graph/badge.svg)](https://codecov.io/gh/unmade/shelf-back)\n\nThis is backend for the Shelf App - a self-hosted file storage.\n\n## Demo\n\n- [https://app.getshelf.cloud/files](https://app.getshelf.cloud/files)\n- [https://api.getshelf.cloud/docs](https://api.getshelf.cloud/docs)\n\n## Development\n\n### Running locally\n\nCreate a new virtual environment:\n\n```bash\npython3 -m venv .venv\nsource ./.venv/bin/activate\n```\n\nInstall requirements:\n\n```bash\npip install -r requirements/base.txt requirements/dev.txt requirements/lint.txt requirements/test.txt\n```\n\nInstall pre-commit hooks:\n\n```bash\npre-commit install\n```\n\nRun services:\n\n```bash\ndocker-compose up -d\n```\n\nApply migration:\n\n```bash\npython manage.py migrate schema.esdl\n```\n\nStart the worker:\n\n```bash\narq app.worker.main.WorkerSettings\n```\n\nStart the application:\n\n```bash\nuvicorn app.api.main:app --host 0.0.0.0 --port 8000\n```\n\n#### Running EdgeDB on Apple Silicon\n\nStarting from version 2.0 EdgeDB has native builds for arm64 arch.\nThe easiest way to run EdgeDB is to install it locally following the\n[official docs](https://www.edgedb.com/install).\n\nUnfortunately running edgedb locally doesn't allow to configure port and\ncertificates, so you have to set `DATABASE_DSN` environment variable to run test:\n\n```bash\nDATABASE__DSN=edgedb://edgedb:root@localhost:10700/edgedb  pytest\n```\n\nTo run a uvicorn you have to unset `DATABASE__DSN` and `DATABASE__EDGEDB_TLS_CA_FILE`\nenvironment variables.\n\n### Adding new requirements\n\nThis project relies on [pip-tools](https://github.com/jazzband/pip-tools) to manage\nrequirements.\nTo add a new one update one of the *.in files in [requirements](requirements) directory,\nand then run:\n\n```bash\npip-compile requirements/{updated_file}.in\n```\n\nTo sync with your env:\n\n```bash\npip-sync requirements/base.txt [requirements/test.txt] ...\n```\n\n### Testing\n\n```bash\npytest\n```\n\n\u003e Before running tests, make sure EdgeDB instance is up and running. Test runner will\n\u003e create a new database and drop it after.\n\n### Building a Docker image\n\nNormally, a docker image is built in CI whenever there is a new tag.\n\nTo build a docker image locally:\n\n```bash\ndocker build . -t shelf_back:0.1.0 --build-arg app_version=0.1.0\n```\n\nOptionally, you can provide two environment variables to autocreate a\nsuperuser on the first image run:\n\n- `SHELF_SUPERUSER_USERNAME` - a superuser username\n- `SHELF_SUPERUSER_PASSWORD` - a superuser password\n\n## Environment variables\n\n|Name                          | Required | Default | Description|\n|:-----------------------------|:-------- |:------- |:-----------|\n|APP_NAME                      | - | Shelf  | Application name |\n|APP_DEBUG                     | - | False  | Whether to run app in debug mode |\n|APP_VERSION                   | - | dev    | Application version. Normally, this env is set during build |\n|AUTH__ACCESS_TOKEN_TTL        | - | 15m    | A time-to-live of the access token. |\n|AUTH__SECRET_KEY              | + | -      | Application secret key. This is used to provide cryptographic signing, and should be set to a unique, unpredictable value |\n|AUTH__SERVICE_TOKEN           | - | None   | A service token that is used to authorize external services in internal API. |\n|AUTH__REFRESH_TOKEN_TTL       | - | 3d     | A time-to-live of the refresh token. |\n|CACHE__BACKEND_DSN            | - | mem:// | Cache backend DSN. See options [here](https://github.com/Krukov/cashews) |\n|CACHE__DISK_CACHE_MAX_SIZE    | - | -      | Client cache size limit in bytes. Can be set in a format like \"512MB\", \"1GB\" |\n|CORS__ALLOWED_ORIGINS         | - | []     | A comma-separated list of origins that should be permitted to make cross-origin requests |\n|DATABASE__DSN                 | - | -      | Database DSN. If not set, then fallback to EdgeDB envs |\n|DATABASE__EDGEDB_TLS_CA_FILE  | - | -      | Path to TLS Certificate file to connect to the database. If not set, then fallback to EDGEDB_TLS_CA |\n|DATABASE__EDGEDB_TLS_SECURITY | - | -      | Set the TLS security mode |\n|FEATURES__MAX_FILE_SIZE_TO_THUMBNAIL | - | 20MB | Thumbnails won't be generated for files larger than specified size. |\n|FEATURES__MAX_IMAGE_PIXELS | - | 89_478_485 | Don't process images if the number of pixels in an image is over limit. |\n|FEATURES__PHOTOS_LIBRARY_PATH | - | Photos/Library | All media files within that path will appear in the Photos. |\n|FEATURES__PRE_GENERATED_THUMBNAIL_SIZES | - | [72, 768, 2880] | Thumbnail sizes that are automatically generated on file upload. |\n|FEATURES__SIGN_UP_DISABLED    | - | False  | Whether sign up is disabled or not |\n|FEATURES__SHARED_LINKS_DISABLED | - | False  | Whether via link disabled. Note, this setting doesn't affect superusers. |\n|FEATURES__UPLOAD_FILE_MAX     | - | 100MB | Maximum upload file size. Default to 100 MB |\n|FEATURES__VERIFICATION_REQUIRED | - | False | Whether user account has to be verified to upload files. |\n|INDEXER__URL                  | - | None   | A URL to the Indexer service. If not specified, the file won't be indexed. |\n|INDEXER__TIMEOUT              | - | 10     | A timeout to wait response from indexer. |\n|MAIL__TYPE                    | - | smtp   | Backend to use for sending emails. |\n|MAIL__SENDER                  | - | \u003cno-reply@getshelf.cloud\u003e  | Email sender on behalf of application. |\n|MAIL__SMTP_HOSTNAME           | - | localhost  | SMTP hostname. |\n|MAIL__SMTP_PORT               | - | 1025   | SMTP port. |\n|MAIL__SMTP_USERNAME           | - | None   | SMTP username. |\n|MAIL__SMTP_PASSWORD           | - | None   | SMTP password. |\n|MAIL__SMTP_USE_TLS            | - | false  | Whether to use TLS connection to SMTP server. |\n|SENTRY__DSN                   | - | None   | Sentry DSN |\n|SENTRY__ENV                   | - | None   | Sentry environment |\n|STORAGE__TYPE                 | - | filesystem | A primary storage type. Either `filesystem` or `s3` options are available |\n|STORAGE__QUOTA                | - | None   | Default storage quota per account in bytes. If not set, then account has unlimited storage. Can be set in a format like \"512MB\", \"1GB\"  |\n|STORAGE__FS_LOCATION          | - | ./data | FileSystem Storage location. Path should be provided without trailing slash |\n|STORAGE__S3_LOCATION          | + | -      | S3 location |\n|STORAGE__S3_ACCESS_KEY_ID     | - | -      | S3 access key id. Required only if `s3` storage type is used |\n|STORAGE__S3_SECRET_ACCESS_KEY | - | -      | S3 secret access key. Required only if `s3` storage type is used |\n|STORAGE__S3_BUCKET_NAME       | - | shelf  | S3 bucket to use to store files. Required only if `s3` storage type is used |\n|STORAGE__S3_REGION_NAME       | - | -      | S3 region. Required only if `s3` storage type is used |\n|WORKER__BROKER_DSN            | + | -      | Worker broker DSN |\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funmade%2Fshelf-back","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funmade%2Fshelf-back","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funmade%2Fshelf-back/lists"}