{"id":18708408,"url":"https://github.com/refactor-group/refactor-platform-rs","last_synced_at":"2025-04-12T10:34:22.730Z","repository":{"id":205887922,"uuid":"692494382","full_name":"Jim-Hodapp-Coaching/refactor-platform-rs","owner":"Jim-Hodapp-Coaching","description":"A platform designed for coaches and leaders to level up engineers and achieve specific growth outcomes","archived":false,"fork":false,"pushed_at":"2024-10-29T18:56:23.000Z","size":1024,"stargazers_count":2,"open_issues_count":8,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-29T20:46:07.654Z","etag":null,"topics":["backend","coaching","coaching-management-system","mentoring","rust","software-engineering"],"latest_commit_sha":null,"homepage":"https://refactorcoach.com","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Jim-Hodapp-Coaching.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-16T16:46:38.000Z","updated_at":"2024-10-28T14:14:11.000Z","dependencies_parsed_at":"2024-01-04T01:10:50.224Z","dependency_job_id":"c8fcdda2-e8eb-4530-af60-3b1759e3eecb","html_url":"https://github.com/Jim-Hodapp-Coaching/refactor-platform-rs","commit_stats":null,"previous_names":["jim-hodapp-coaching/refactor-platform-rs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jim-Hodapp-Coaching%2Frefactor-platform-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jim-Hodapp-Coaching%2Frefactor-platform-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jim-Hodapp-Coaching%2Frefactor-platform-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jim-Hodapp-Coaching%2Frefactor-platform-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jim-Hodapp-Coaching","download_url":"https://codeload.github.com/Jim-Hodapp-Coaching/refactor-platform-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223511460,"owners_count":17157521,"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","coaching","coaching-management-system","mentoring","rust","software-engineering"],"created_at":"2024-11-07T12:23:17.424Z","updated_at":"2025-04-12T10:34:22.718Z","avatar_url":"https://github.com/Jim-Hodapp-Coaching.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build \u0026 Tests (backend)](https://github.com/Jim-Hodapp-Coaching/refactor-platform-rs/actions/workflows/ci.yml/badge.svg)](https://github.com/Jim-Hodapp-Coaching/refactor-platform-rs/actions/workflows/ci.yml)\n\n# Refactor Coaching \u0026 Mentoring Platform\n\n## Backend\n\n## Intro\n\nA Rust-based backend that provides a web API for various client applications (e.g. a web frontend) that facilitate the coaching and mentoring of software engineers.\n\nThe platform itself is useful for professional independent coaches, informal mentors and engineering leaders who work with individual software engineers and/or teams by providing a single application that facilitates and enhances your coaching practice.\n\n## Basic Local DB Setup and Management\n\n## Running the Database Setup Script\n\n1. Ensure you have PostgreSQL installed and running on your machine. If you're using macOS, you can use\n[Postgres.app](https://postgresapp.com/) or install it with Homebrew:\n\n    ```shell\n    brew install postgresql\n    ```\n\n2. Make sure you have the `dbml2sql` and SeaORM CLI tools installed. You can install them with:\n\n    ```shell\n    npm install -g @dbml/cli\n    ```\n\n    ```shell\n    cargo install sea-orm-cli\n    ```\n\n3. Run the script with default settings:\n\n    ```shell\n    ./scripts/rebuild_db.sh\n    ```\n\n    This will create a database named `refactor_platform`, a user named `refactor`, and a schema named `refactor_platform`.\n\n4. If you want to use different settings, you can provide them as arguments to the script:\n\n    ```shell\n    ./scripts/rebuild_db.sh my_database my_user my_schema\n    ```\n\n    This will create a database named `my_database`, a user named `my_user`, and a schema named `my_schema`.\n\n5. If you want seeded test data in your database, run:\n\n   ```shell\n   cargo run --bin seed_db\n   ```\n\nPlease note that the script assumes that the password for the new PostgreSQL user is `password`. If you want to use a different password, you'll need to modify the script accordingly.\n\n## Starting the Backend\n\nTo run the backend directly outside of a container:\n\nThe first example will start the backend with log level DEBUG and attempt to connect to a Postgres DB server on the same machine with user `refactor` and password `password` on port `5432` and selecting the database named `refactor_platform`.\n\n```bash\ncargo run --  --tiptap-url https://\u003cTIPTAP_APP_ID\u003e.collab.tiptap.cloud --tiptap-auth-key=\u003cTIPTAP_API_SECRET\u003e --tiptap-jwt-signing-key=\u003cTIPTAP_CLOUD_APP_SECRET\u003e --tiptap-app-id=\u003cTIPTAP_APP_ID\u003e\n```\n\nTo run with a custom Postgresql connection string:\n\n```bash\ncargo run -- -d postgres://refactor:my_password@localhost:5432/refactor_platform --tiptap-url https://\u003cTIPTAP_APP_ID\u003e.collab.tiptap.cloud --tiptap-auth-key=\u003cTIPTAP_API_SECRET\u003e --tiptap-jwt-signing-key=\u003cTIPTAP_CLOUD_APP_SECRET\u003e --tiptap-app-id=\u003cTIPTAP_APP_ID\u003e\n```\n\nTo run with an additional list of allowed cross-site network origins:\n\n```bash\ncargo run -- --allowed-origins=\"http://192.168.1.2:3000,https://192.168.1.2:3000\" --tiptap-url https://\u003cTIPTAP_APP_ID\u003e.collab.tiptap.cloud --tiptap-auth-key=\u003cTIPTAP_API_SECRET\u003e --tiptap-jwt-signing-key=\u003cTIPTAP_CLOUD_APP_SECRET\u003e --tiptap-app-id=\u003cTIPTAP_APP_ID\u003e\n```\n\n---\n\n## Basic Container DB Setup and Management\n\n_This Rust-based backend/web API connects to a PostgreSQL database. It uses Docker and Docker Compose for local development and deployment, including utilities for database management and migrations. You can run PostgreSQL locally (via Docker) or remotely by configuring environment variables._\n\n---\n\n### Building and Running Locally or Remotely in Containers\n\n1. **Install Prerequisites**:\n   - [Docker](https://www.docker.com/products/docker-desktop) (20+)\n   - [Docker Compose](https://docs.docker.com/compose/install/) (1.29+)\n\n2. **Clone the Repository**:\n\n   ```bash\n   git clone \u003crepository-url\u003e\n   cd \u003crepository-directory\u003e\n   ```\n\n3. **Set Environment Variables**:\n   - For **local PostgreSQL**, create a `.env.local` file and set `POSTGRES_HOST=postgres`.\n   - For **remote PostgreSQL**, use a `.env.remote-db` file with `POSTGRES_HOST` pointing to the external database.\n\n4. **Build and Start the Platform**:\n   - Local PostgreSQL:\n\n     ```bash\n     docker-compose --env-file .env.local up --build\n     ```\n\n   - Remote PostgreSQL:\n\n     ```bash\n     docker-compose --env-file .env.remote-db up --build\n     ```\n\n5. **Access the API**:\n   - Visit `http://localhost:\u003cSERVICE_PORT\u003e` in your browser or API client.\n\n### Key Commands\n\n- **Stop all containers**:\n\n  ```bash\n  docker-compose down\n  ```\n  \n   **Note**: This will stop all containers, including the database.\n  \n- **Rebuild and restart**:\n\n  ```bash\n  docker-compose up --build\n  ```\n\n- **View logs**:\n\n  ```bash\n  docker-compose logs \u003cservice\u003e\n  ```\n\n_For additional commands, database utilities, and debugging tips, check the [Container README](docs/runbooks/Container-README.md)._\n\n---\n\n## Project Directory Structure\n\n`docs` - project documentation including architectural records, DB schema, API docs, etc\n\n`domain` - Layer of abstraction above `entity_api` and intended to encapsulate most business logic. Ex. interactions between `entity_api` and network calls to the outside world.\n\n`entity_api` - data operations on the various `Entity` models\n\n`entity` - shape of the data models and the relationships to each other\n\n`migration` - relational DB SQL migrations\n\n`scripts` - contains handy developer-related scripts that make working with this codebase more straightforward\n\n`service` - CLI flags, environment variables, config handling and backend daemon setup\n\n`src` - contains a main function that initializes logging and calls all sub-services\n\n`web` - API endpoint definition, routing, handling of request/responses, controllers\n\n---\n\n## Advanced / Manual DB operations\n\n### Set Up Database Manually\n\nNote: these are commands meant to run against a real Postgresql server with an admin level user.\n\n```sql\n--create new database `refactor_platform`\nCREATE DATABASE refactor_platform;\n```\n\nChange to the refactor_platform DB visually if using app like Postico, otherwise change using the\nPostgresql CLI:\n\n```sh\n\\c refactor_platform\n```\n\n```sql\n--create new database user `refactor`\nCREATE USER refactor WITH PASSWORD 'password';\n--create a new schema owned by user `refactor`\nCREATE SCHEMA IF NOT EXISTS refactor_platform AUTHORIZATION refactor;\n--Check to see that the schema `refactor_platform` exists in the results\nSELECT schema_name FROM information_schema.schemata;\n--Grant all privileges on schema `refactor_platform` to user `refactor`\nGRANT ALL PRIVILEGES ON SCHEMA refactor_platform TO refactor;\n```\n\n### Run Migrations\n\nNote: this assumes a database name of `refactor_platform`\n\n```bash\nDATABASE_URL=postgres://refactor:password@localhost:5432/refactor_platform sea-orm-cli migrate up -s refactor_platform\n```\n\n### Generate a new Entity from Database\n\nNote that to generate a new Entity using the CLI you must ignore all other tables using the `--ignore-tables` option. You must add the option for _each_ table you are ignoring.\n\n```bash\n DATABASE_URL=postgres://refactor:password@localhost:5432/refactor_platform sea-orm-cli generate entity  -s refactor_platform -o entity/src -v --with-serde both --serde-skip-deserializing-primary-key --ignore-tables {table to ignore} --ignore-tables {other table to ignore}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frefactor-group%2Frefactor-platform-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frefactor-group%2Frefactor-platform-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frefactor-group%2Frefactor-platform-rs/lists"}