Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/JorLOrT/rappi2/llms.txt

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

This quickstart walks you through spinning up a local Rappi2 instance using Docker Compose, initializing the database, creating the default admin user, and authenticating against the API for the first time.
1

Clone and configure

Clone the repository and create your .env file from the provided example:
git clone https://github.com/JorLOrT/rappi2.git
cd rappi2
cp .env.example .env
Open .env and set the required variables:
# PostgreSQL
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=rappi2

# MongoDB
MONGO_USER=admin
MONGO_PASSWORD=admin
MONGO_DB=rappi2_mongo

# Connection URLs (update credentials if you changed them above)
DATABASE_URL=postgresql+asyncpg://postgres:postgres@postgres:5432/rappi2
MONGO_URL=mongodb://admin:admin@mongodb:27017/

# JWT signing key — replace this before deploying to any shared environment
SECRET_KEY=change_me_to_a_random_64_char_string_in_production

# Token lifetimes
ACCESS_TOKEN_EXPIRE_MINUTES=15
REFRESH_TOKEN_EXPIRE_DAYS=7

# OpenRouteService key (required for route planning; optional otherwise)
ORS_API_KEY=your_openrouteservice_api_key_here
Never commit a real SECRET_KEY to version control. Generate one with openssl rand -hex 32 and keep it out of your repository.
2

Start with Docker Compose

Build and start all three services (PostgreSQL, MongoDB, and the API):
docker-compose up -d
Docker Compose will wait for both databases to pass their health checks before starting the API container. Once complete, the API is available at http://localhost:8000.
3

Run database migrations

Apply all Alembic migrations to initialize the PostgreSQL schema:
docker-compose exec api alembic upgrade head
This creates every table the API depends on. Run this command again whenever you pull changes that include new migrations.
4

Seed the admin user

Populate the default roles (Admin, Despachador, Conductor, Cliente), grant the Admin role wildcard permissions, and create the initial admin user:
docker-compose exec api python -m scripts.seed_admin
The script creates the user admin with password admin123. Change this password immediately in any environment accessible to others.
The seed script is idempotent — running it more than once will not create duplicate records.
5

Make your first request

Log in to obtain a JWT token pair, then call a protected endpoint to confirm everything is working.Step 5a — Log in:
curl -s -X POST http://localhost:8000/api/auth/login \
  -F "username=admin" \
  -F "password=admin123"
The response contains an access_token and a refresh_token:
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "refresh_token": "dGhpcyBpcyBhIHJhbmRvbSByZWZyZXNoIHRva2Vu...",
  "token_type": "bearer",
  "expires_in": 900
}
Step 5b — Call a protected endpoint:
curl -s http://localhost:8000/api/auth/me \
  -H "Authorization: Bearer <your_access_token>"
A successful response returns your user profile, confirming the API is running and your token is valid.
The interactive API explorer is available at http://localhost:8000/docs. You can authorize there using the Authorize button and test every endpoint without writing curl commands.

Build docs developers (and LLMs) love