{"id":27287740,"url":"https://github.com/bbougon/crm-pilates","last_synced_at":"2025-04-11T20:27:19.944Z","repository":{"id":47605545,"uuid":"371093946","full_name":"bbougon/crm-pilates","owner":"bbougon","description":null,"archived":false,"fork":false,"pushed_at":"2024-01-11T20:00:11.000Z","size":709,"stargazers_count":0,"open_issues_count":5,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-04-17T06:03:54.057Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/bbougon.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}},"created_at":"2021-05-26T16:04:45.000Z","updated_at":"2022-01-02T23:23:30.000Z","dependencies_parsed_at":"2023-10-16T04:26:19.751Z","dependency_job_id":"46de6c3d-9760-4446-a9df-cc134abb1ad3","html_url":"https://github.com/bbougon/crm-pilates","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/bbougon%2Fcrm-pilates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbougon%2Fcrm-pilates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbougon%2Fcrm-pilates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbougon%2Fcrm-pilates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bbougon","download_url":"https://codeload.github.com/bbougon/crm-pilates/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248475113,"owners_count":21110025,"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":[],"created_at":"2025-04-11T20:27:19.143Z","updated_at":"2025-04-11T20:27:19.932Z","avatar_url":"https://github.com/bbougon.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CRM Pilates\n\nCRM Pilates is an application to manage Pilates classroom for small and medium Pilates offices.\n\n## Development\n### Prerequisites\n\n- CRM Pilates is made over `python 3.9.9`\n- You need to install poetry\n- You need to install postgres and libpq in order to run tests and run the app locally\n- You will need a private key to encrypt / decrypt user password (default is provided for tests purpose only), to generate one, just run:\n  `openssl rand -hex 32` and keep this key in a safe place (provide the value to the environment key `SECRET_KEY`)\n\n**Documentation:**\n- [New domain exploration](https://miro.com/app/board/uXjVOxwEdAo=/)\n- [Old domain exploration](https://miro.com/app/board/o9J_leSmQNU=/)\n\nEverything is in the Makefile\n\n### Create a user\nRun a python interpreter in your shell once everything is installed and run the following\n```shell\n\u003e\u003e\u003e from passlib.context import CryptContext\n\u003e\u003e\u003e pwd_context = CryptContext(schemes=[\"bcrypt\"], deprecated=\"auto\")\n\u003e\u003e\u003e pwd_context.hash('password')\n'$2b$12$t.OhZvTO6xAFtUrqdrxkgO9z23VlK0wzkMKg4fESjll6CwayKswXu'\n```\n\nAnd then execute the following SQL request on your database\n```sql\nINSERT INTO users VALUES (1, 'bertrand', '$2b$12$t.OhZvTO6xAFtUrqdrxkgO9z23VlK0wzkMKg4fESjll6CwayKswXu')\n```\n\n### ADR\n\nNat Pryce [ADR tools](https://github.com/npryce/adr-tools)\n\nADR index is kept [here](./adr/README.md)\n\n### Installation\n\n  `make install` will install the virtual env, all needed dependencies, setup your local environment and setup local sqlite database\n\n### Tests\n\n1. in tests folder run `docker-compose up` in order to boot a postgres database for tests\n1. `make test` will run all the tests (you can specify `args=\"--db-type sqlite\"` or `args=\"--db-type postgres\"` to run tests under sqlite (by default) or postgres)\n1. `make coverage` will run coverage\n\n**NB:**\n\n- Postgres event store test use the postgres test connection (that means you need a postgres installed locally to run the tests)\n\n### Run the API\n\n#### Locally\n  `make run` will run the application with all the modules\n\n#### Docker\nThere is a `Dockerfile` within root directory. It builds the api then creates an image.\n\nThere is also a `docker-compose.yml` file\n\n- `docker-compose --env-file .env.local up` will:\n    1. boot a postgres database container named `crm-pilates-postgres` (login: `crm-pilates`, password: `example`)\n    2. boot an adminer container\n    3. boot the `crm-pilates-api` and load the events persisted in database\n\n### API\n\nThe API documentation is available in 3 formats:\n- [openapi](http://localhost:8081/openapi.json)\n- [swagger](http://localhost:8081/docs)\n- [redoc](http://localhost:8081/redoc)\n\nResources are authenticated by a JWT with header `Authorization: Bearer TOKEN_VALUE`.\nTo retrieve a token, you need to authenticate on `/token` (see below)\n\n#### Authentication\n1. Run the API (see above section)\n2. Insert a user in user table (encrypt your password with the key provided in docker-compose :warning: for local installation purpose only!)\n3. Use the `curl` command line as below\n   ```bash\n   curl -X POST http://localhost:8081/token -d 'username=[USERNAME]\u0026password=[PASSWORD]' -H 'Content-Type: application/x-www-form-urlencoded' -v | jq\n   ```\n   Expected result:\n   ```bash\n    {\n       \"token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJiZXJ0cmFuZCIsImV4cCI6MTY2MTM2NjQ3Mn0.VM37LH4JR0AHn_sn1iGBADhpDh9SoOM9wDc4oDdzmYo\",\n       \"type\": \"bearer\"\n    }\n   ```\n4. The token is valid during 30 minutes\n\n\n##### Create a classroom\n1. Run the API (see above section)\n2. Use the `curl` command line as below\n   ```bash\n   curl http://localhost:8081/classrooms -X POST --data '{\"name\": \"advanced class\", \"start_date\": \"2021-05-10T10:00\", \"position\": 3, \"duration\": {\"duration\": 50, \"unit\": \"MINUTE\"}, \"subject\": \"MAT\"}' -H \"Content-Type: application/json\" -H \"Authorization: Bearer [TOKEN_VALUE]\" -v | jq\n   ```\n   Expected result:\n   ```bash\n    {\n      \"name\": \"advanced class\",\n      \"id\": \"33da6f12-efda-4c16-b8af-e5e822fc5459\",\n      \"position\": 3,\n      \"start_date\": \"2021-05-10T10:00:00\",\n      \"stop_date\": null,\n      \"duration\": {\n        \"duration\": 50,\n        \"unit\": \"MINUTE\"\n      }\n    }\n   ```\n\n##### Create a client\n1. Run the API (see above section)\n2. Use the `curl` command line as below\n   ```bash\n   curl http://localhost:8081/clients -X POST --data '{\"firstname\": \"John\", \"lastname\": \"Doe\"}' -H \"Content-Type: application/json\" -H \"Authorization: Bearer [TOKEN_VALUE]\" -v | jq\n   ```\n   Expected result:\n   ```bash\n    {\n      \"firstname\": \"John\",\n      \"lastname\": \"Doe\",\n      \"id\": \"33da6f12-efda-4c16-b8af-e5e822fc5459\",\n    }\n   ```\n\n#### Add attendees to a classroom\n1. Run the API (see above section)\n1. Create a classroom (see above section)\n1. Use the `curl` command line as below\n   ```bash\n   curl http://localhost:8081/classrooms/{id} -X PATCH --data '{\"attendees\": [{\"id\": \"A_CLIENT_ID\"}]}' -H \"Content-Type: application/json\" -H \"Authorization: Bearer [TOKEN_VALUE]\" -v\n   ```\n   Expected result:\n   ```bash\n    HTTP/1.1 204 No Content\n   ```\n\n#### Checkin\n1. Run the API (see above section)\n1. Add attendees to a classroom (see above section)\n1. Use the `curl` command line as below\n   ```bash\n   curl http://localhost:8081/sessions/checkin -X POST --data '{\"classroom_id\": \"CLASSROOM_ID\", \"session_date\": \"SESSION_DATE\", \"attendee\": \"ATTENDEE_ID\"}' -H\"Content-Type: application/json\" -H \"Authorization: Bearer [TOKEN_VALUE]\" -v | jq\n   ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbougon%2Fcrm-pilates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbbougon%2Fcrm-pilates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbougon%2Fcrm-pilates/lists"}