Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/fatelessdev/translogiX/llms.txt

Use this file to discover all available pages before exploring further.

TranslogiX uses PostgreSQL as its database and Drizzle ORM for schema management and queries. This page covers starting the database, applying the schema, seeding initial data, and opening the visual Drizzle Studio GUI.

Connection string

The DATABASE_URL environment variable must be set before running any database commands or starting the application:
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/translogix
This matches the credentials defined in the Docker Compose file. Update the host, port, username, or password if you are connecting to an external PostgreSQL instance.

Starting the database with Docker Compose

The repository ships with a docker-compose.yml that starts a PostgreSQL 16 container pre-configured for TranslogiX.
1

Start the container

From the project root, run:
docker compose up -d
The -d flag runs the container in the background. Docker will pull the postgres:16 image on first run.
2

Wait for the health check to pass

The container runs pg_isready -U postgres -d translogix every 5 seconds. Once it returns healthy, the database is ready to accept connections. You can verify the status with:
docker compose ps

Docker Compose service details

SettingValue
Service namepostgres
Container nametranslogix-postgres
Imagepostgres:16
Exposed port5432
Database nametranslogix
Usernamepostgres
Passwordpostgres
Data volumepgdata (persisted across restarts)
Data is stored in a named Docker volume called pgdata. Stopping the container with docker compose down preserves your data. Add the -v flag (docker compose down -v) only if you want to wipe the volume and start fresh.

Drizzle scripts

The following npm scripts manage the database schema and data. Run them from the project root with your .env file in place.

db:push — sync schema without migrations

Compares the current schema in lib/db/schema.ts against the live database and applies any differences directly. Useful during active development when you do not need a migration history.
pnpm db:push

db:migrate — run migration files

Applies pending SQL migration files from the drizzle/ output directory in order. Use this in CI pipelines and production deployments to apply schema changes safely.
pnpm db:migrate
Always run db:migrate against a backup in production. Migrations that drop columns or tables are irreversible.

db:seed — seed initial data

Runs scripts/seed.ts using tsx to populate the database with initial records. Run this once after the schema has been applied to get a working dataset.
pnpm db:seed

db:studio — open Drizzle Studio

Starts the Drizzle Studio web GUI, which lets you browse tables, inspect rows, and run queries through a browser interface.
pnpm db:studio
Drizzle Studio opens at https://local.drizzle.studio by default.

Schema overview

The schema is defined in lib/db/schema.ts and covers the following tables:
TablePurpose
usersApplication users with role (ADMIN, TRANSPORTER, DRIVER, CUSTOMER)
sessionsBetterAuth session records
accountsBetterAuth account/credential records
verificationsBetterAuth email verification tokens
transportersTransporter companies
vehiclesVehicles belonging to transporters (TRUCK, DUMPER, VAN, OTHER)
routesNamed routes with distance, estimated time, and billing rates
shipmentsShipment records linking transporters, vehicles, and routes
tracking_updatesGPS location updates for in-transit shipments
Use db:push while iterating on the schema locally, and switch to db:migrate when you are ready to create a reviewable migration file for deployment.

Build docs developers (and LLMs) love