{"id":22184811,"url":"https://github.com/undp/satlomas-back","last_synced_at":"2025-03-24T19:25:51.470Z","repository":{"id":42847292,"uuid":"262398427","full_name":"undp/satlomas-back","owner":"undp","description":"SatLomas platform backend, REST API and background jobs","archived":false,"fork":false,"pushed_at":"2023-03-04T16:59:26.000Z","size":50188,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-30T00:14:42.920Z","etag":null,"topics":["backend","satlomas"],"latest_commit_sha":null,"homepage":"https://satlomas.pe.undp.org/","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/undp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-08T18:25:38.000Z","updated_at":"2023-05-12T23:43:58.000Z","dependencies_parsed_at":"2022-09-22T02:51:41.853Z","dependency_job_id":null,"html_url":"https://github.com/undp/satlomas-back","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/undp%2Fsatlomas-back","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/undp%2Fsatlomas-back/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/undp%2Fsatlomas-back/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/undp%2Fsatlomas-back/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/undp","download_url":"https://codeload.github.com/undp/satlomas-back/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245336494,"owners_count":20598706,"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":["backend","satlomas"],"created_at":"2024-12-02T10:14:10.309Z","updated_at":"2025-03-24T19:25:51.449Z","avatar_url":"https://github.com/undp.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SatLomas backend\n\nThis is the repository for SatLomas platform backend, which contains the REST\nAPI and background jobs.\n\n\n## Requirements\n\n* Python 3\n* PostgreSQL 9.4+ with PostGIS 2 and Timescale extensions\n* GDAL, Proj, etc.\n\n\n## Configuration\n\nCopy `env.sample` as `.env`, and edit it to suit your needs. The following\nvariables are mandatory:\n\n- `SECRET_KEY`: This is used to provide cryptographic signing, and should be\n  set to a unique, unpredictable string value.\n- `SCIHUB_USER`: SciHub username. Needed for downloading Sentinel-1/2 datasets.\n- `SCIHUB_PASS`: SciHub password. Needed for downloading Sentinel-1/2 datasets.\n- `MODIS_USER`: USGS username. Needed for downloading MODIS datasets.\n- `MODIS_PASS`: USGS password. Needed for downloading MODIS datasets.\n\n\n## Development\n\n### With Docker\n\nThere is a set of Docker images and docker-compose configuration file that\nmanages all services:\n\n* `api` Django app instance for API and Admin\n* `worker`: RQ worker instance\n* `db`: PostgreSQL instance with TimescaleDB and PostGIS extensions\n\nYou only need to have Docker and Docker Compose installed.\n\nFirst step is to run `script/docker-reset.sh` to create database, run\nmigrations and create super user.\n\nAfterwards, run `docker-compose up`. If you want to run everything in the\nbackground, use `docker-compose start`, and afterwards `docker-compose stop` to\nstop everything.\n\nIf you need to reset again, just run `script/docker-reset.sh`.  To stop\neverything and delete all volumes and networks run `docker-compose down`.\n\nYoun can use `script/docker-run.sh` to run commands inside API container.\nFor example: `script/docker-run.sh pipenv run ./manage.py migrate` to run new\nmigrations.\n\n\n### Without Docker\n\n\u003e **Note**: The following instructions are for Ubuntu 18.04.  You can check\n\u003e TimescaleDB instalation\n\u003e [guide](https://docs.timescale.com/latest/getting-started/installation) if\n\u003e you are using another OS.\n\nAdd PostgreSQL's third party repository to get the latest PostgreSQL packages\n(if you are using Ubuntu older than 19.04):\n\n```sh\n# `lsb_release -c -s` should return the correct codename of your OS\necho \"deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -c -s)-pgdg main\" | sudo tee /etc/apt/sources.list.d/pgdg.list\nwget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -\nsudo apt-get update\n```\n\nAdd TimescaleDB's third party repository and install TimescaleDB, which will\ndownload any dependencies it needs from the PostgreSQL repo:\n\n```sh\n# Add TimescaleDBs PPA\nsudo add-apt-repository ppa:timescale/timescaledb-ppa\nsudo apt-get update\n\n# Now install appropriate package for PG version\nsudo apt install timescaledb-postgresql-11\n```\n\nTune database for TimescaleDB:\n\n```sh\nsudo timescaledb-tune\n```\n\nInstall Python and other dependencies\n\n```sh\nsudo apt-get install \\\n  gdal-bin \\\n  gettext \\\n  libgdal-dev \\\n  libpq-dev \\\n  libproj-dev \\\n  libspatialindex-dev \\\n  python3 \\\n  python3-dev \\\n  python3-pip \\\n  redis-server\n```\n\nInstall PostGIS 3 extension for this PostgreSQL.\n\n```sh\nsudo apt-get install postgresql-11-postgis-3\n```\n\nRestart PostgreSQL instance:\n\n```sh\nsudo service postgresql restart\n```\n\nCreate a superuser role for your currently logged-in user:\n\n```sh\nsudo -u postgres createuser -s $USER\n```\n\nCreate the database:\n\n```sh\ncreatedb satlomas\n```\n\nSet user password for the user you just created (`satlomas`). Please replace\n`foobar` for a long and difficult to guess password:\n\n```sh\npsql satlomas -c \"ALTER USER $USER WITH PASSWORD 'foobar'\"\n```\n\nAdd TimescaleDB and PostGIS extensions to the database\n\n```sh\npsql satlomas -c \"CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE\"\npsql satlomas -c \"CREATE EXTENSION IF NOT EXISTS postgis CASCADE\"\npsql satlomas -c \"CREATE EXTENSION IF NOT EXISTS postgis_raster CASCADE\"\n```\n\n* Copy `env.sample` and edit it to suit your needs. See the Configuration\n  section above.\n\n```sh\ncp env.sample .env\n```\n\n* Install Python dependencies using Pipenv. Install it first if you don't have it:\n\n```\npip install --user -U pipenv\npipenv install\npipenv install django-anymail[mailgun] django-rest-auth[with_social] django-storages[google]\n```\n\nThen inside a pipenv shell (use `pipenv shell`) you should first do the following:\n\n* Run migrations: `./manage.py migrate`\n* Create superuser: `./manage.py createsuperuser`\n\nNow you can:\n\n* Run server: `./manage.py runserver`\n* Run tests: `./manage.py test`\n\nWhen deploying for the first time:\n\n* Set `DEBUG=0` and `ALLOWED_HOSTS` list with domains/subdomains and IPs\n* Also, set a long unique `SECRET_KEY`\n* Collect statics with `./manage.py collectstatic`\n\n### Honcho\n\nYou can use [Honcho](https://honcho.readthedocs.io) to fire up everything (web\nserver, workers and Flower) on your dev machine. Simple run `honcho start`.\nYou can also start specific processes: `honcho start web`, `honcho start\nworker`, etc.\n\nSee [Procfile](Procfile).\n\n### Translations\n\nWhen adding new translated strings:\n\n* Run `django-admin makemessages`\n* Update .po files\n* Run `django-admin compilemessages`\n\n### Deployment\n\nCopy the configuration files for systemd found at `tools/systemd`.\n\n`gunicorn` start the Django service using gunicorn.\n\n```sh\nsudo cp tools/systemd/gunicorn.service /etc/systemd/system/\nsudo systemctl start gunicorn.service\nsudo systemctl enable gunicorn.service\n```\n\n`rqworker@` manages multiple workers for background jobs.\n\n```sh\nsudo cp tools/systemd/rqworker@.service /etc/systemd/system/\nsudo systemctl start rqworker@.service\nsudo systemctl enable rqworker@.service\n```\n\nIf you make changes to those files after this, make sure then that systemd is\nreloaded and restart services:\n\n```sh\nsudo systemctl daemon-reload\nsudo systemctl restart gunicorn rqworker@*\n```\n\nInstall nginx. Copy the configuration files found on `tools/nginx` and restart\nnginx.\n\n```\nsudo apt install nginx\nsudo cp tools/nginx/* /etc/nginx/sites-available/\nsudo ln -s /etc/nginx/sites-available/satlomas* /etc/nginx/sites-enabled/\nsudo systemctl restart nginx\n```\n\nInstall certbot and configure it for free SSL certificates and automatic\nrenewal:\n\n```sh\nsudo apt-get update\nsudo apt-get install software-properties-common\nsudo add-apt-repository universe\nsudo add-apt-repository ppa:certbot/certbot\nsudo apt-get update\n```\n\n```sh\nsudo apt-get install certbot python-certbot-nginx\n```\n\n```sh\nsudo certbot --nginx\n```\n\n## License\n\nSee [LICENSE.txt](LICENSE.txt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fundp%2Fsatlomas-back","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fundp%2Fsatlomas-back","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fundp%2Fsatlomas-back/lists"}