{"id":19596276,"url":"https://github.com/peroxy/starsky-backend","last_synced_at":"2025-04-23T08:17:21.065Z","repository":{"id":53781720,"uuid":"291246827","full_name":"peroxy/starsky-backend","owner":"peroxy","description":"Starsky is a management application for employee scheduling.","archived":false,"fork":false,"pushed_at":"2021-09-15T13:26:24.000Z","size":717,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-23T08:17:14.785Z","etag":null,"topics":["employee","employee-management","employee-scheduling","schedule","scheduling","starsky","starsky-backend"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peroxy.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}},"created_at":"2020-08-29T10:09:03.000Z","updated_at":"2024-01-19T10:27:38.000Z","dependencies_parsed_at":"2022-08-19T14:01:12.807Z","dependency_job_id":null,"html_url":"https://github.com/peroxy/starsky-backend","commit_stats":null,"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peroxy%2Fstarsky-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peroxy%2Fstarsky-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peroxy%2Fstarsky-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peroxy%2Fstarsky-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peroxy","download_url":"https://codeload.github.com/peroxy/starsky-backend/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250395288,"owners_count":21423400,"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":["employee","employee-management","employee-scheduling","schedule","scheduling","starsky","starsky-backend"],"created_at":"2024-11-11T08:52:38.925Z","updated_at":"2025-04-23T08:17:21.049Z","avatar_url":"https://github.com/peroxy.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Starsky backend :star:\n\nStarsky backend represents the API and database portion of starsky application for employee scheduling. \nIt uses Java (Spring Boot) for REST API, PostgreSQL for data storage and Nginx for reverse proxy in production. \n\nFront-end React application is located in a repository called [starsky-frontend](https://github.com/peroxy/starsky-frontend).\n\nIt also uses the transactional email API that is located in a repository called [starsky-mail](https://github.com/peroxy/starsky-mail).\n\n## Requirements :clipboard:\n\n- [docker](https://docs.docker.com/get-docker/)\n- [docker-compose](https://docs.docker.com/compose/install/) (at least 3.8 version support)\n\n## Development :computer:\n\n### Running with docker\n\nPlease note that this has only been tested with docker on Ubuntu 20.04.\n\n1. Download source files and go to `docker` directory:\n\n```shell script\ngit clone https://github.com/peroxy/starsky-backend.git\ncd starsky-backend/docker\n```\n\n2. Build and run the entire stack:\n\n```shell script\ndocker-compose up\n```\n\n3. You will now be able to access:\n\n- API at http://localhost:8080/ and swagger-ui at http://localhost:8080/api/swagger-ui.html\n- database at http://localhost:5432/\n\nYou can access the `starsky` database by using credentials (this can be changed in the `docker-compose.override.yml` file):\n- username: `starsky`\n- password: `starsky`\n\n### Debugging\nYou can run the API locally using your favorite Java IDE:  \n1. Run the database:\n\n```shell script\ncd starsky-backend/docker\ndocker-compose up database\n```\n2. Set Spring active profiles: `dev` and `local`\n3. Run and debug the application \n\n### Testing\nWe are using JUnit5 for tests with Spring Boot. An in-memory H2 database is used. \n\nNo extra configuration is needed, just run: `gradle test`\n\n### OpenAPI client\nYou can generate an OpenAPI client by running backend API locally, then running (for example TypeScript client):\n\n```shell\ndocker run --rm --network host -v \"${PWD}:/local\" openapitools/openapi-generator-cli generate -i http://localhost:8080/api/v3/api-docs -g typescript -o /local/out/ts\n```\n\n## Deployment :rocket:\n\nWe host entire infrastructure on Azure, specifically using Azure Virtual Machine.\n\n### Server requirements\n\nThe server (in our case Azure VM) must have these installed:\n\n- [docker](https://docs.docker.com/get-docker/),\n- [docker-compose](https://docs.docker.com/compose/install/) (at least 3.8 version support).\n\n#### Setup on Azure Virtual Machine:\n1. Create Azure Virtual Machine with Ubuntu installed and setup your public SSH key. Ubuntu 18.04 was used at the time of writing this.\n2. Enable SSH (port 22) and whitelist your IP.\n3. Connect to your machine:\n\n   ```shell script\n   ssh username@ipAddress\n   ```\n\n4. [Install docker](https://docs.docker.com/get-docker/):\n\n    ```shell script\n    curl -fsSL https://get.docker.com -o get-docker.sh\n    sudo usermod -aG docker \u003cyour-user\u003e\n    ```\n   Log out and log back in to be able to use `docker` without `sudo`.\n\n\n5. [Install docker-compose](https://docs.docker.com/compose/install/):\n\n   ```shell script\n    sudo curl -L \"https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)\" -o /usr/local/bin/docker-compose\n    sudo chmod +x /usr/local/bin/docker-compose\n    ```\n\n6. Generate a SSH key:bb\n\n    ```shell script\n    ssh-keygen -t rsa -b 4096 -c \"starsky_deploy\"\n    ```\n\n#### SSL Setup\nCurrently, SSL is done manually by using ZeroSSL and copying certificates to Azure VM.\n\n1. Generate a certificate, you will get 3 files: certificate.crt, private.key, ca_bundle.crt.\n2. Copy them to Azure VM with rsync:\n\n```shell\ncd ~/certs\nrsync ./* user@host:~/certs\n```\n\n3. Restart Nginx on Azure VM.\n\n### Repository secrets\n\nThese are the required secrets that should be stored inside Github repository secrets:\n\n- Dockerhub:\n   - `DOCKERHUB_USERNAME`\n   - `DOCKERHUB_TOKEN` - see [Create an access token](https://docs.docker.com/docker-hub/access-tokens/#create-an-access-token) for more information\n- PostgreSQL:\n   - `POSTGRES_USER`\n   - `POSTGRES_PASSWORD` - don't make it too long, there were some issues with authentication with a 128 character password, even though it should be supported in theory...\n- Server host (Azure VM):\n   - `REMOTE_HOST` - remote host IP address / domain to SSH into\n   - `REMOTE_USER` - username to SSH with\n   - `SERVER_SSH_KEY` - private SSH key (OpenSSH, for example the contents of your `~/.ssh/id_rsa` key) to connect to your server\n- API:\n   - `STARSKY_JWT_SECRET` - needed for generating JWT tokens, use a random 32 character secret\n   - `STARSKY_FRONTEND_REGISTER_URL` - needed to send invite links with proper URL\n\n### How to deploy\n\nPush a tag `*.*.*` (e.g. `1.0.3`) to `master` branch and it will automatically deploy everything via Github workflow.\nSee `.github/main.yml` workflow for more info.\n\nIn short, it does this if it gets triggered by a new tag:\n\n- Takes source code from `master` branch and extracts the newest version from tag.\n- Configures environment variables used by docker containers from Github repository's secrets.\n- Builds and pushes all apps as Docker images to DockerHub.\n- Copies environment variables and docker-compose files to Azure VM.\n- Stops `starsky-backend` containers on Azure VM, pulls the newest images and starts the containers again.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperoxy%2Fstarsky-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperoxy%2Fstarsky-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperoxy%2Fstarsky-backend/lists"}