What it does
Plans live in organizations. One login can belong to several of them, with a different role in each. Anyone who signs in can create an organization and becomes its owner.
Rotations & coverage
Group tasks, set rotation cycles and optional due times. If the planned person is away, the next available member covers that occurrence and the plan shows why. Uncovered slots are flagged.
Availability
Repeating working-hour patterns (every 1–52 weeks), one-off calendar changes, and absences such as holiday, sick or training. Absences always win over schedules and manual assignments.
Time tracking
Start a timer or add blocks by hand. Overtime is measured against each member's contracted weekly hours and schedule, with monthly and yearly balances.
Expenses
Submit expenses with receipts (PDF or image, up to 10 MB). Administrators approve, reject with a reason, and mark as reimbursed. Receipts live in S3-compatible storage.
Audit log
Every change is recorded in the same transaction as the change itself, with field-level before and after values. Entries are never edited or deleted.
Calendar feed
Each member gets a personal iCal link to subscribe to their assignments from any calendar app.
Roles
Roles are per organization and stored on the person's roster entry.
| Role | Can do |
|---|---|
| Owner | Everything an administrator can, plus transfer ownership and delete the organization. Exactly one per organization. |
| Administrator | Configure the plan and roster, correct anyone's time, approve expenses, read the audit log, rename the organization. |
| Team member | Read the plan, complete occurrences, manage their own schedule and absences, track their own time, submit their own expenses. |
How it's built
A Vite-built React single-page app talks to a Bun/Elysia REST API backed by PostgreSQL through Drizzle. Sign-in goes through your own OIDC identity provider using Better Auth. In production a single Elysia process serves both the built SPA and the API from one origin.
Quick start
Runs the whole stack on your machine: PostgreSQL, a pre-configured Keycloak for sign-in, and Garage for receipt storage.
You need
- Bun 1.4.5
- Docker with Compose
- Git
-
Get the code
git clone https://github.com/philiplehmann/mainty.git cd mainty
-
Create your
.envcp .env.example .env
The example already contains working local values for Keycloak, PostgreSQL and Garage.
Set a real secret. Replace
BETTER_AUTH_SECRETin.envwith a random string of at least 32 characters, for example the output ofopenssl rand -base64 32. -
Start the backing services
docker compose up -d postgres keycloak garage
.env.examplesetsCOMPOSE_FILE=compose.yaml:compose.local.yaml, which publishes the ports on127.0.0.1. PostgreSQL listens on host port15432so it doesn't clash with another local database. -
Install dependencies and create the schema
bun install bun run db:push
-
Run the app
bun run dev
Open http://localhost:3000. Vite serves the app with hot reload and proxies
/apito the API on port 3001. -
Sign in and create an organization
A fresh database has no organizations. Sign in with the local Keycloak test account below, create an organization, and you become its owner. Then add people by email.
Account Email Password Administrator admin@example.comadmin123Team member member@example.commember123To try the member view, add
member@example.comto your organization and sign in as that user. The Keycloak admin console at localhost:8080 usesadmin/admin. These credentials are for local development only.
Deploying for real
The production image bundles the SPA and the API in one container on port 3000.
CI publishes it to Docker Hub as philiplehmann/mainty, or you can build it yourself:
docker compose --env-file .env build app docker compose --env-file .env up -d app
You need to provide:
- A PostgreSQL database and
DATABASE_URL. - An OIDC identity provider (Keycloak, Entra ID, Google Workspace, …). Register this redirect URI:
${BETTER_AUTH_URL}/api/auth/sso/callback/${OIDC_PROVIDER_ID}. The provider must return a verified email inOIDC_DOMAIN. - S3-compatible storage for receipts (optional; without it everything works except receipt upload, which answers 503).
Required environment variables
| Variable | Purpose |
|---|---|
DATABASE_URL | PostgreSQL connection URL |
BETTER_AUTH_URL | Public origin of the app; base for auth callbacks |
BETTER_AUTH_SECRET | Random secret, at least 32 characters |
OIDC_PROVIDER_ID | Stable provider ID used in the callback URL |
OIDC_ISSUER | Issuer URL; discovery at /.well-known/openid-configuration |
OIDC_DISCOVERY_URL | Optional override when the issuer isn't reachable from the app |
OIDC_DOMAIN | Email domain accepted for sign-in |
OIDC_CLIENT_ID / OIDC_CLIENT_SECRET | OIDC client credentials |
S3_ENDPOINT, S3_REGION, S3_BUCKET, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY | Receipt storage (optional) |
Replace every example secret from .env.example and the Compose files before going live: the Better Auth secret, the OIDC client secret, the Garage key and GARAGE_RPC_SECRET.
Database migrations
db:push is for development databases. Deployed databases apply the migrations in drizzle/, which ship in the Docker image: run bun src/db/migrate.ts from the image before the app starts, for example as a Kubernetes initContainer or a pre-deploy Job. Concurrent runs are serialized, so one initContainer per replica is safe. After a schema change, add a migration with bun run db:generate.
Everyday commands
bun run dev | Apply the schema and run Vite and the API with hot reload |
bun run start | Build the SPA and serve it plus the API from one process |
bun run test | Unit tests |
bun run test:e2e:installbun run test:e2e | Install Chromium, then run browser tests against the production image with an isolated PostgreSQL and Keycloak |
bun run lint · typecheck · knip | Biome, TypeScript and unused-code checks |
bun run db:generate | Generate Drizzle migrations after a schema change |
bun run db:migrate | Apply the migrations in drizzle/ |
The complete reference, covering scheduling rules, time and overtime calculation, authorization and database constraints, is in the README.