{"id":16345396,"url":"https://github.com/unclechu/carma-ruamc-fork","last_synced_at":"2026-01-11T06:03:32.875Z","repository":{"id":42360152,"uuid":"145720464","full_name":"unclechu/carma-ruamc-fork","owner":"unclechu","description":"CaRMa when I was working on fork for RuAMC ","archived":false,"fork":false,"pushed_at":"2023-01-04T10:47:23.000Z","size":14893,"stargazers_count":0,"open_issues_count":11,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-03T03:41:31.292Z","etag":null,"topics":["crm","haskell","purescript"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/unclechu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-22T14:27:45.000Z","updated_at":"2019-12-30T21:15:08.000Z","dependencies_parsed_at":"2023-02-02T09:15:19.171Z","dependency_job_id":null,"html_url":"https://github.com/unclechu/carma-ruamc-fork","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/unclechu/carma-ruamc-fork","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unclechu%2Fcarma-ruamc-fork","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unclechu%2Fcarma-ruamc-fork/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unclechu%2Fcarma-ruamc-fork/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unclechu%2Fcarma-ruamc-fork/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unclechu","download_url":"https://codeload.github.com/unclechu/carma-ruamc-fork/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unclechu%2Fcarma-ruamc-fork/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28293188,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T04:44:51.577Z","status":"ssl_error","status_checked_at":"2026-01-11T04:44:44.232Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["crm","haskell","purescript"],"created_at":"2024-10-11T00:31:27.442Z","updated_at":"2026-01-11T06:03:32.859Z","avatar_url":"https://github.com/unclechu.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CaRMa\n\n[![CircleCI](https://circleci.com/gh/ruamk/carma/tree/master.svg?style=svg)](https://circleci.com/gh/ruamk/carma/tree/master)\n[![Docker](https://images.microbadger.com/badges/image/ruamc/carma-bundle.svg)](https://microbadger.com/images/ruamc/carma-bundle)\n\n## About documentation\n\nThis is important. Project lives relatively for many years (since 2012), and\ndevelopers switches from one to another and this makes it more clear we need a\ngood documentation and comments for the code and everything must be written in\nEnglish (some parts still written in Russian, since for a long period of time it\nhave been used and developed only in single country) to make it available to\nwork on the project to anyone (any serious developer supposed to be able to deal\nwith English, if you don't then go learn it or please leave the profession, no\noffence).\n\nAny documentation related to the project supposed to be placed in [docs][docs]\ndirectory using Markdown (but for some exceptional cases it may be something\ndifferent but please use open standard formats such as XML, HTML, ODF, CSV, SVG,\nLaTeX, etc. but not DOC, DOCX, XLS, PSD and other formats from closed\necosystems).\n\nSome documents for the project have been written as separated Google Docs files,\nthey're supposed to be migrated to this repo (to the docs [docs][docs]), they\nalso was written in Russian, supposed to be rewritten in English. Only very\nsecret documents may live separately.\n\nPlease keep in mind that you, as a developer, may die unexpectedly (or you just\nmay leave the poject) as any other creature, and even if you don't (at least not\nunexpectedly) after you other people probably will work with this project.\nPlease do your job like you die just after your last commit that means not to be\nparanoid, depressive or crazy but means that it would be a good idea to leave a\ngood comments for your code, for your changes, it would be a good idea to add or\nexpand some documents which explains things for developers, and try to avoid\nad-hoc fixes/features which is almost always hard to deal with. Just try to not\nleave stuff with thoughs like \"I'll refactor this later\", \"I'll add comments for\nthis later\", etc., please make sure you did right thing before you commit, at\nleast make sure another developer can deal with it after you, it may be adding\n**TODO** or **FIXME** comments which explains what you or another developer\nsupposed to do. For a function or a monad it would be a good idea to write few\nsimple usage examples and explain what issues it helps/supposed to solve.\n\nWhen your changes or new features affects deploy process, please check that docs\nare still exhaustive, and project may be deployed just using these instructions\nwithout contacting you personally.\n\n## Building\n\nRefer to [`.circleci/config.yml`][ci-config] for full building instructions.\n\n### tools/builder.sh\n\nThere's [tool](tools/builder.sh) that could build everything from scratch in\nparallel for you, just run:\n\n```bash\ntools/builder.sh -p all\n```\n\nOr get detailed usage info of this tool to be able to run particular tasks with\ndifferent options:\n\n```bash\ntools/builder.sh --help\n```\n\n#### Production release\n\nIf your next release doesn't require to apply any migrations, to create or\nupdate any configs then your production release could be built by this command:\n\n```bash\ntools/builder.sh -p --production --clean all\n```\n\nIf your server setup implies **CaRMa**'s binaries to be presented in\n`~/.local/bin/` then you should run after that:\n\n```bash\nstack install\n```\n\nAnd restart proper **CaRMa** services.\n\n*P.S. You could find instructions about how to apply database migrations below.*\n\n### Backend (Haskell)\n\n#### Generic\n\n##### Prepare database\n\n1. Install PostgreSQL 9.3 (this is what production servers use) and\n   PostGIS (extension for PostgreSQL).\n\n   We have [docker container][docker/dev-pg-9.3] with exact PostgreSQL version\n   for development, you could use it.\n\n   Create a database named `carma`:\n\n   ```postgresql\n   createdb carma\n   ```\n\n2. Add roles:\n\n   ```postgresql\n   createuser -s carma\n   createuser carma_db_sync\n   createuser carma_geo\n   createuser carma_sms\n   createuser mail_svc\n   createuser fmuser\n   createuser pavel.golovnin\n   createuser reportgen\n   ```\n\n   `carma` is the superuser which owns the database and is used to run\n   DB migration scripts.\n\n3. Set passwords:\n\n   ```bash\n   psql carma -c \"alter user carma with password 'pass'\"\n   psql carma -c \"alter user carma_db_sync with password 'pass'\"\n   ```\n\n4. Unpack and recover a database snapshot (note that this needs to run\n   as a PostgreSQL superuser - for example, prepend with `sudo -u postgres`):\n\n   ```bash\n   psql carma -f 2017-05-29_03-15_carma.sql\n   ```\n\n   Or if you use [docker/dev-pg-9.3][] mentioned above,\n   you could do it by this command:\n\n   ```bash\n   psql -h 127.0.0.1 -U carma_db_sync -d carma -f 2017-05-29_03-15_carma.sql\n   ```\n\n   In case you have a gzipped database dump (`.sql.gz` extension):\n\n   ```bash\n   zcat 2017-05-29_03-15_carma.sql.gz | psql carma\n   ```\n\n   For [docker/dev-pg-9.3][]:\n\n   ```bash\n   zcat 2017-05-29_03-15_carma.sql.gz | psql -h 127.0.0.1 -U carma_db_sync -d carma\n   ```\n\n5. You might need to apply some migrations if your database snapshot is older\n   than current state of git-branch. To do so run:\n\n   ```bash\n   (cd database \u0026\u0026 ./db.sh update)\n   ```\n\n   Or if you use [docker/dev-pg-9.3][]:\n\n   ```bash\n   (cd database \u0026\u0026 env PGHOST=127.0.0.1 PGUSER=carma_db_sync PGPASSWORD=pass ./db.sh update-devel)\n   ```\n\n##### Build backend executables\n\n1. Install [Haskell Stack][haskell-stack]. Check that it works:\n\n   ```bash\n   stack --numeric-version\n   # 1.6.5\n   ```\n\n2. Clone **CaRMa** Git repository:\n\n   ```bash\n   git clone git@github.com:ruamk/carma\n   cd carma\n   ```\n\n3. Add log files:\n\n   ```bash\n   mkdir -p srv/log \u0026\u0026 \u003e srv/log/access.log \u0026\u0026 \u003e srv/log/error.log\n   ```\n\n4. Build the backend:\n\n   ```bash\n   stack build --install-ghc\n   ```\n\n   P.S. When you rebuild backend on production servers you need to run\n\n   ```bash\n   stack install\n   ```\n\n   after to install executables to `$HOME/.local/bin` dir which is used to run\n   backend from by init-scripts.\n\n5. Copy default configuration files to your local directory\n   (which is ignored from git-index):\n\n   ```bash\n   cp -r srv/snaplets-default srv/snaplets\n   cp -r carma-mobile-server/snaplets-default carma-mobile-server/snaplets\n   ```\n\n   Keep in mind that if you change database configuration or credentials to\n   access to it you need to update these files (links points to default ones):\n\n   - [srv/snaplets/persist/devel.cfg](srv/snaplets-default/persist/devel.cfg)\n   - [srv/snaplets/postgresql-simple/devel.cfg](srv/snaplets-default/postgresql-simple/devel.cfg)\n   - [carma-mobile-server/snaplets/postgresql-simple/devel.cfg](carma-mobile-server/snaplets-default/postgresql-simple/devel.cfg)\n\n6. **WARNING!** Before going to next step you supposed to build\n   [frontend](#frontend) first, because templates for backend must be built\n   by frontend toolchain before start.\n\n7. Run the server from `srv/` directory:\n\n   ```bash\n   (cd srv \u0026\u0026 stack exec carma -- -p 8000)\n   ```\n\n8. Check that the server works:\n\n   ```bash\n   curl localhost:8000/meta\n   ```\n\n9. **WARNING!** To work with *Geo* API (e.g. search on maps, addresses, etc.)\n   you need to run [Nominatim Mediator][nominatim-mediator] microservice,\n   to do so locally:\n\n   1. Go to the directory of that package:\n\n      ```bash\n      cd carma-nominatim-mediator\n      ```\n\n   2. Copy default config:\n\n      ```bash\n      cp app.cfg.default app.cfg\n      ```\n\n   3. Run the microservice (being in `carma-nominatim-mediator` directory):\n\n      ```bash\n      stack exec carma-nominatim-mediator\n      ```\n\n   4. Now you can ashure that it's working by this command:\n\n      ```bash\n      curl -v 'http://127.0.0.1:8165/reverse-search/ru-RU,ru/37.378847,55.558741'\n      ```\n\n#### macOS\n\nOn macOS with `openssl` and `icu4c` installed via Homebrew, build with\n\n```bash\nstack build --extra-include-dirs=/usr/local/opt/openssl/include/ --extra-include-dirs=/usr/local/opt/icu4c/include/ --extra-lib-dirs=/usr/local/opt/openssl/lib/ --extra-lib-dirs=/usr/local/opt/icu4c/lib/\n```\n\n#### Docker\n\nAlternatively, to build the server inside Docker and package all\nexecutables in a container:\n\n```bash\nstack docker pull\nstack --docker image container\n```\n\nIf you're on Linux, you can just build with `stack --docker build` and\nrun the app outside Docker. You will not be able to run the app built\nthis way on macOS or Windows.\n\nIf the container has no access to your SSH keys (which may be the case\nwhen using a token), use `stack dot` prior to building the image to\nquickly fetch dependencies (`.stack-work/downloaded` directory is\nshared between the container and the host anyways).\n\nNote that this container lacks frontend resources necessary to launch\n**CaRMa** - see below for how to build the whole bundle.\n\n### Frontend\n\nCheck that you have proper versions of **node.js** and **npm**:\n\n```bash\nprintf 'node: %s, npm: %s\\n' \"`node --version`\" \"`npm --version`\"\n# node: v8.11.1, npm: 5.6.0\n```\n\nTo build front-end from scratch (development build):\n\n```bash\ncd srv\nnpm install\nnpm run build\nnpm run build-backend-templates\n```\n\nIf you need to just rebuild it again (after some changes for instance) run:\n\n```bash\nnpm run build\n```\n\nTo build bundle for production instead of for development run:\n\n```bash\ncd srv\nnpm install\nnpm run prod-build\nnpm run build-backend-templates\n```\n\nIf you're about to deploy next release to the production server, just run\n(this includes `npm i`, `clean-build-backend-templates` and `prod-clean-build`):\n\n```bash\nnpm run prod-release\n```\n\nYou also could run a watcher in background to rebuild client code automatically\nwhen sources change by using this command (development mode):\n\n```bash\nnpm run watch\n```\n\nTo clean everything run:\n\n```bash\nnpm run clean\nnpm run clean-backend-templates\n```\n\nThere's also single command to do the same:\n\n```bash\nnpm run full-clean\n```\n\n#### \"Pure\" frontend\n\n**WARNING!** Do not forget to also build \"pure\" frontend,\nthe commands look almost the same as you saw above.\nSee [\"pure\" frontend README][pure-readme] for details.\n\nThis is partly rewritten frontend (some rewritten parts of it),\nsome parts of it included to the main frontend using `\u003ciframe\u003e`s.\n\nIdeally the whole frontend must be rewritten in this \"pure\" version.\n\n### CI build\n\n[CircleCI][ci] is configured to build CaRMa on every push. If you have\nDocker installed, you may use [CircleCI CLI tool][ci-cli] to perform\nbuilds in the same environment as on CI server:\n\n```bash\ncircleci build --job build_client\ncircleci build --job build_server\n```\n\nJobs run in an auto-removed container, so at the moment you may\nonly use them to test that the build finishes successfully.\n\n### Docker bundle\n\n*This is an EXPERIMENTAL workflow*\n\nIf you build the frontend and the backend Docker image, you can also\nbuild a bundle image containing both:\n\n```bash\ncd srv/\ndocker build -t carma-bundle .\n```\n\nCaRMa server executable inside the container is located at\n`/usr/local/bin/carma`.\n\nThis is what [`build_bundle`][ci-config] CI step does.\n\nAlternatively, you may skip building CaRMa altogether and just pick an\nimage from [ruamc/carma-bundle][hub-bundle] repo on Docker Hub.\n\nTo run the bundle, use [carma-bundle.yml][] Docker Compose file, which\ncombines a CaRMa bundle and PostgreSQL.\n\nRequired steps:\n\n1. Create carma-db-data volume using [docker/dev-pg-9.3][] container.\n\n2. Clone [carma-configs][] and edit CaRMa configs path in `volumes:`\n   section of [carma-bundle.yml][].\n\nThe command to run the bundle is\n\n```bash\ndocker-compose -f docker/carma-bundle.yml up\n```\n\n## Running\n\n1. Get a recent database snapshot. Backup folder with daily production\n   snapshots is mounted on `carma-test` server at\n   `/var/backups/allbackups/postgresql_carma`:\n\n   ```bash\n   scp \u003cYOUR_LOGIN\u003e@192.168.10.13:/var/backups/allbackups/postgresql_carma/2017-05-29_03-15_carma.sql.gz .\n   ```\n\n[carma-bundle.yml]: docker/carma-bundle.yml\n[carma-configs]: https://github.com/ruamk/carma-configs\n[ci-cli]: https://circleci.com/docs/2.0/local-jobs/#installing-the-cli-locally\n[ci-config]: .circleci/config.yml\n[ci]: https://circleci.com/gh/ruamk/carma\n[haskell-stack]: https://docs.haskellstack.org/en/stable/README/\n[hub-bundle]: https://hub.docker.com/r/ruamc/carma-bundle/tags/\n[docker/dev-pg-9.3]: docker/dev-pg-9.3\n[pure-readme]: srv/resources/assets/pure/README.md\n[nominatim-mediator]: carma-nominatim-mediator/\n[docs]: docs/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funclechu%2Fcarma-ruamc-fork","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funclechu%2Fcarma-ruamc-fork","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funclechu%2Fcarma-ruamc-fork/lists"}