Self-hosted · Open source

Maintenance planning your team can actually follow.

Mainty plans recurring maintenance tasks across a team: who is on rotation, who is working or away, and who covers when someone is out. It also tracks time and expenses, and records every change in an audit log.

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.

RoleCan do
OwnerEverything an administrator can, plus transfer ownership and delete the organization. Exactly one per organization.
AdministratorConfigure the plan and roster, correct anyone's time, approve expenses, read the audit log, rename the organization.
Team memberRead 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.

BunElysiaReact 19TanStack Router & Query Tailwind CSS 4Drizzle ORMPostgreSQL 18 Better Auth (OIDC)Garage (S3)Playwright

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
  1. Get the code

    git clone https://github.com/philiplehmann/mainty.git
    cd mainty
  2. Create your .env

    cp .env.example .env

    The example already contains working local values for Keycloak, PostgreSQL and Garage.

    Set a real secret. Replace BETTER_AUTH_SECRET in .env with a random string of at least 32 characters, for example the output of openssl rand -base64 32.

  3. Start the backing services

    docker compose up -d postgres keycloak garage

    .env.example sets COMPOSE_FILE=compose.yaml:compose.local.yaml, which publishes the ports on 127.0.0.1. PostgreSQL listens on host port 15432 so it doesn't clash with another local database.

  4. Install dependencies and create the schema

    bun install
    bun run db:push
  5. Run the app

    bun run dev

    Open http://localhost:3000. Vite serves the app with hot reload and proxies /api to the API on port 3001.

  6. 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.

    AccountEmailPassword
    Administratoradmin@example.comadmin123
    Team membermember@example.commember123

    To try the member view, add member@example.com to your organization and sign in as that user. The Keycloak admin console at localhost:8080 uses admin / 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 in OIDC_DOMAIN.
  • S3-compatible storage for receipts (optional; without it everything works except receipt upload, which answers 503).

Required environment variables

VariablePurpose
DATABASE_URLPostgreSQL connection URL
BETTER_AUTH_URLPublic origin of the app; base for auth callbacks
BETTER_AUTH_SECRETRandom secret, at least 32 characters
OIDC_PROVIDER_IDStable provider ID used in the callback URL
OIDC_ISSUERIssuer URL; discovery at /.well-known/openid-configuration
OIDC_DISCOVERY_URLOptional override when the issuer isn't reachable from the app
OIDC_DOMAINEmail domain accepted for sign-in
OIDC_CLIENT_ID / OIDC_CLIENT_SECRETOIDC client credentials
S3_ENDPOINT, S3_REGION, S3_BUCKET, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEYReceipt 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 devApply the schema and run Vite and the API with hot reload
bun run startBuild the SPA and serve it plus the API from one process
bun run testUnit tests
bun run test:e2e:install
bun run test:e2e
Install Chromium, then run browser tests against the production image with an isolated PostgreSQL and Keycloak
bun run lint · typecheck · knipBiome, TypeScript and unused-code checks
bun run db:generateGenerate Drizzle migrations after a schema change
bun run db:migrateApply the migrations in drizzle/

The complete reference, covering scheduling rules, time and overtime calculation, authorization and database constraints, is in the README.