A 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.
The 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.
-
Ensure you have PostgreSQL installed and running on your machine. If you're using macOS, you can use Postgres.app or install it with Homebrew:
brew install postgresql
-
Make sure you have the
dbml2sql
and SeaORM CLI tools installed. You can install them with:npm install -g @dbml/cli
cargo install sea-orm-cli
-
Run the script with default settings:
./scripts/rebuild_db.sh
This will create a database named
refactor_platform
, a user namedrefactor
, and a schema namedrefactor_platform
. -
If you want to use different settings, you can provide them as arguments to the script:
./scripts/rebuild_db.sh my_database my_user my_schema
This will create a database named
my_database
, a user namedmy_user
, and a schema namedmy_schema
. -
If you want seeded test data in your database, run:
cargo run --bin seed_db
Please 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.
Note: these are commands meant to run against a real Postgresql server with an admin level user.
--create new database `refactor_platform`
CREATE DATABASE refactor_platform;
Change to the refactor_platform DB visually if using app like Postico, otherwise change using the Postgresql CLI:
\c refactor_platform
--create new database user `refactor`
CREATE USER refactor WITH PASSWORD 'password';
--create a new schema owned by user `refactor`
CREATE SCHEMA IF NOT EXISTS refactor_platform AUTHORIZATION refactor;
--Check to see that the schema `refactor_platform` exists in the results
SELECT schema_name FROM information_schema.schemata;
--Grant all privileges on schema `refactor_platform` to user `refactor`
GRANT ALL PRIVILEGES ON SCHEMA refactor_platform TO refactor;
Note: this assumes a database name of refactor_platform
DATABASE_URL=postgres://refactor:password@localhost:5432/refactor_platform sea-orm-cli migrate up -s refactor_platform
Note 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.
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}
To run the backend directly outside of a container:
cargo run -- -l DEBUG -d postgres://refactor:password@localhost:5432/refactor_platform
This 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
.
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.
-
Install Prerequisites:
- Docker (20+)
- Docker Compose (1.29+)
-
Clone the Repository:
git clone <repository-url> cd <repository-directory>
-
Set Environment Variables:
- For local PostgreSQL, create a
.env.local
file and setPOSTGRES_HOST=postgres
. - For remote PostgreSQL, use a
.env.remote-db
file withPOSTGRES_HOST
pointing to the external database.
- For local PostgreSQL, create a
-
Build and Start the Platform:
-
Local PostgreSQL:
docker-compose --env-file .env.local up --build
-
Remote PostgreSQL:
docker-compose --env-file .env.remote-db up --build
-
-
Access the API:
- Visit
http://localhost:<SERVICE_PORT>
in your browser or API client.
- Visit
-
Stop all containers:
docker-compose down
Note: This will stop all containers, including the database.
-
Rebuild and restart:
docker-compose up --build
-
View logs:
docker-compose logs <service>
For additional commands, database utilities, and debugging tips, check the Container README.
docs
- project documentation including architectural records, DB schema, API docs, etc
entity_api
- data operations on the various Entity
models
entity
- shape of the data models and the relationships to each other
migration
- relational DB SQL migrations
scripts
- contains handy developer-related scripts that make working with this codebase more straightforward
service
- CLI flags, environment variables, config handling and backend daemon setup
src
- contains a main function that initializes logging and calls all sub-services
web
- API endpoint definition, routing, handling of request/responses, controllers