{"id":15294934,"url":"https://github.com/x1unix/sbda-ledger","last_synced_at":"2025-10-07T06:31:25.410Z","repository":{"id":54962265,"uuid":"326479775","full_name":"x1unix/sbda-ledger","owner":"x1unix","description":":shipit: Backend for a social expenses ledger for groups of friends.","archived":true,"fork":false,"pushed_at":"2021-01-19T12:43:23.000Z","size":181,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-17T05:52:34.336Z","etag":null,"topics":["docker","expense","golang-app-server","golang-examples","ledger"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":false,"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/x1unix.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":"2021-01-03T18:59:06.000Z","updated_at":"2024-12-23T22:42:55.000Z","dependencies_parsed_at":"2022-08-14T07:31:06.399Z","dependency_job_id":null,"html_url":"https://github.com/x1unix/sbda-ledger","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/x1unix%2Fsbda-ledger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x1unix%2Fsbda-ledger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x1unix%2Fsbda-ledger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x1unix%2Fsbda-ledger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/x1unix","download_url":"https://codeload.github.com/x1unix/sbda-ledger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235599953,"owners_count":19016191,"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":["docker","expense","golang-app-server","golang-examples","ledger"],"created_at":"2024-09-30T17:08:02.211Z","updated_at":"2025-10-07T06:31:20.076Z","avatar_url":"https://github.com/x1unix.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ledger\n\n\u003e Backend for a social expenses ledger for groups of friends.\n\nIn this system, users are part of groups; a user can add an expense to the group, specifying how the expense has to be split. At any time, a user can request its balance, that will be the outstanding credits and debits for that users inside the group.\n\nAPI documentation is available as [OpenAPI/Swagger spec](https://editor.swagger.io/?url=https://raw.githack.com/x1unix/sbda-ledger/master/api/swagger.yaml).\n\n## Prerequisites\n\n* Docker\n* docker-compose\n* **GNU** Make\n* Go 1.12+\n    * *Optionals*:\n    * [golang-migrate](https://github.com/golang-migrate/migrate) (for manual sql migration)\n    * [golangci-lint](https://golangci-lint.run/) as linter\n\n## Tests\n\n### End-to-end\n\nIntegration tests (e2e) are described in [e2e](e2e) directory.\nTests cover all cases, including data structure and routes validation.\n\n* Start environment with `docker-compose start`\n* Start back-end API with `make run`\n* Run tests with `make e2e`\n\n### Unit\n\nI didn't have much time to cover code with unit tests, so most effort was done on integration testing.\nIntegration tests cover all cases that could be covered by unit tests, so I don't think that it's critical.\n\n## Usage\n\n### Development\n\n* Start DB and Redis containers with `docker-compose start`\n  * Pre-create containers *before* start using `docker-compose up -d` (one time operation)\n* `make run`\n\n#### Migrations\n\nDefault location for migrations is `db/migrations`. Use `make new-migration` to create a new migration.\n\nUse `LGR_NO_MIGRATION` environment variable to omit on-start migration.\n\n### Production\n\nUse `make` to build the project.\nOutput binary will be located at `target` directory.\n\n#### Configuration\n\nThe service can be configured using environment variables, or a [config file](config.example.yaml).\n\nUse `-c` flag to provide path to a config file.\n\n#### Environment variables\n\nSee [config.go](internal/config/config.go) for more options.\n\n| Name                 | Type   | Defaults                           | Description                                      |\n|----------------------|--------|------------------------------------|--------------------------------------------------|\n| `LGR_HTTP_ADDR`      | string | `:8800`                            | Interface to listen by HTTP server               |\n| `LGR_DB_ADDRESS`     | string | `postgres://localhost:5432/ledger` | Postgres DB address (URL or DSN)                 |\n| `LGR_REDIS_ADDRESS`  | string | `localhost:6379`                   | Redis server address                             |\n| `LGR_REDIS_USER`     | string | -                                  | Redis username                                   |\n| `LGR_REDIS_PASSWORD` | string | -                                  | Redis password                                   |\n| `LGR_REDIS_DB`       | int    | -                                  | Redis database number                            |\n| `LGR_MIGRATIONS_DIR` | string | `db/migrations`                    | Path to directory containing migration scripts   |\n| `LGR_VERSION_TABLE`  | string | `schema_migrations`                | Name of a table, which contains database version |\n| `LGR_SCHEMA_VERSION` | int    | -                                  | Force set schema version (dangerous)             |\n| `LGR_NO_MIGRATION`   | bool   | `false`                            | Skip database migration                          |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fx1unix%2Fsbda-ledger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fx1unix%2Fsbda-ledger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fx1unix%2Fsbda-ledger/lists"}