Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Muhammadbugaje/trustride/llms.txt

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

TrustRide is an ASGI-first Django application. In production it runs under Daphne to support both HTTP and WebSocket connections (used by the real-time chat and notification features). Nginx sits in front as a reverse proxy, PostgreSQL stores relational data, Redis powers the Celery task queue, and Celery Beat handles all scheduled jobs. This guide walks through every step — from a fresh Ubuntu server to a fully running deployment.
Always set DJANGO_DEBUG=False in production. Running with DEBUG=True exposes full stack traces, disables security headers, and allows any host to connect. See the Configuration reference for the full list of required environment variables.

Prerequisites

Before you begin, confirm the following are available on your target server:
RequirementMinimum versionNotes
Ubuntu20.04 LTS22.04 recommended
Python3.10Required by pyproject.toml target
PostgreSQL14Connection managed via dj-database-url
Redis7Celery broker and optional channel layer
Node.js18Required to build Tailwind CSS assets
NginxAny currentReverse proxy and WebSocket termination

Server Preparation

1

Create a dedicated system user

Run TrustRide under its own non-root user to limit the blast radius of any security issue.
sudo adduser --system --group --home /opt/trustride trustride
2

Install system dependencies

Install Python, PostgreSQL client libraries, Redis, Nginx, and Node.js in one pass.
sudo apt update && sudo apt install -y \
  python3.10 python3.10-venv python3-pip \
  postgresql postgresql-contrib libpq-dev \
  redis-server \
  nginx \
  nodejs npm
Enable and start Redis so it is available before the app boots:
sudo systemctl enable redis-server
sudo systemctl start redis-server
3

Clone the repository and create a virtualenv

sudo -u trustride git clone https://github.com/Muhammadbugaje/trustride.git /opt/trustride/app
cd /opt/trustride/app

python3.10 -m venv /opt/trustride/venv
source /opt/trustride/venv/bin/activate
4

Install Python dependencies

pip install --upgrade pip
pip install -r requirements.txt
Key packages installed include Django 6.0.6, Daphne 4.2.2, Celery 5.6.3, psycopg2-binary 2.9.12, channels 4.3.2, and WhiteNoise 6.12.0.
5

Build Tailwind CSS assets

TrustRide uses Tailwind CSS 4 via the @tailwindcss/cli package. Run the Node.js build step before collecting static files.
npm install
npx tailwindcss -i ./static/css/input.css -o ./static/css/output.css --minify
The package.json does not define a build script by default. Run the npx tailwindcss command directly. Tailwind scans ./templates/**/*.html, ./apps/**/templates/**/*.html, and ./static/**/*.js as defined in tailwind.config.js.

Database Setup

Create a PostgreSQL database and user, then run Django’s migrations to build the schema.
sudo -u postgres psql <<EOF
CREATE USER trustride WITH PASSWORD 'your-strong-password';
CREATE DATABASE trustride OWNER trustride;
GRANT ALL PRIVILEGES ON DATABASE trustride TO trustride;
EOF
Export the connection URL and run migrations:
export DATABASE_URL="postgres://trustride:your-strong-password@localhost:5432/trustride"

python manage.py migrate
python manage.py createsuperuser
Populate initial sample data (optional, useful for staging):
python manage.py shell < populate_sample_data.py

Static Files

WhiteNoise (whitenoise.middleware.WhiteNoiseMiddleware) is already wired into the middleware stack and uses CompressedManifestStaticFilesStorage, so Django serves compressed, cache-busted static assets without a separate CDN. Collect all static files into STATIC_ROOT:
python manage.py collectstatic --noinput
In production the settings file sets STATIC_ROOT = '/home/trustrid/public_html/static'. Adjust this path to match your server layout, then update the Nginx alias directive accordingly.

Daphne ASGI Server

TrustRide’s ASGI entrypoint (trust_ride/asgi.py) uses Django Channels’ ProtocolTypeRouter to route HTTP traffic to the standard Django app and WebSocket connections to the chat consumer. Daphne understands both protocols natively. Start Daphne manually to verify the setup before configuring systemd:
daphne -b 127.0.0.1 -p 8000 trust_ride.asgi:application
Bind to 127.0.0.1 (loopback), not 0.0.0.0, in production. Nginx handles the public-facing connection and proxies inward. Direct exposure of Daphne to the internet is not recommended.

Systemd Service Files

Create systemd units so that Daphne, the Celery worker, and Celery Beat all start automatically on boot and restart after failures.

Daphne web process

# /etc/systemd/system/trustride-daphne.service
[Unit]
Description=TrustRide Daphne ASGI Server
After=network.target postgresql.service redis.service

[Service]
User=trustride
Group=trustride
WorkingDirectory=/opt/trustride/app
EnvironmentFile=/opt/trustride/app/.env
ExecStart=/opt/trustride/venv/bin/daphne \
    -b 127.0.0.1 \
    -p 8000 \
    trust_ride.asgi:application
Restart=on-failure
RestartSec=5
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target

Celery worker

# /etc/systemd/system/trustride-celery.service
[Unit]
Description=TrustRide Celery Worker
After=network.target redis.service

[Service]
User=trustride
Group=trustride
WorkingDirectory=/opt/trustride/app
EnvironmentFile=/opt/trustride/app/.env
ExecStart=/opt/trustride/venv/bin/celery \
    -A trust_ride worker \
    --loglevel=info \
    --logfile=/opt/trustride/logs/celery.log
Restart=on-failure
RestartSec=10
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target

Celery Beat scheduler

# /etc/systemd/system/trustride-celerybeat.service
[Unit]
Description=TrustRide Celery Beat Scheduler
After=network.target redis.service trustride-celery.service

[Service]
User=trustride
Group=trustride
WorkingDirectory=/opt/trustride/app
EnvironmentFile=/opt/trustride/app/.env
ExecStart=/opt/trustride/venv/bin/celery \
    -A trust_ride beat \
    --loglevel=info \
    --scheduler django_celery_beat.schedulers:DatabaseScheduler \
    --logfile=/opt/trustride/logs/celerybeat.log
Restart=on-failure
RestartSec=10
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target
Enable and start all three services:
sudo mkdir -p /opt/trustride/logs
sudo chown trustride:trustride /opt/trustride/logs

sudo systemctl daemon-reload
sudo systemctl enable trustride-daphne trustride-celery trustride-celerybeat
sudo systemctl start  trustride-daphne trustride-celery trustride-celerybeat

Nginx Configuration

Nginx terminates TLS, forwards regular HTTP requests to Daphne, and upgrades /ws/ paths to WebSocket connections (used by the live chat feature in apps/chat).
# /etc/nginx/sites-available/trustride
server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;

    # WebSocket connections (Django Channels / chat)
    location /ws/ {
        proxy_pass http://127.0.0.1:8000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_read_timeout 86400;
    }

    # All other HTTP traffic
    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    # Static files served directly by Nginx (optional but faster)
    location /static/ {
        alias /opt/trustride/app/staticfiles/;
        expires 30d;
        add_header Cache-Control "public, immutable";
    }

    # Media files (not used when Cloudinary is active)
    location /media/ {
        alias /opt/trustride/app/media/;
    }
}
Enable the site and reload Nginx:
sudo ln -s /etc/nginx/sites-available/trustride /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

SSL with Let’s Encrypt

Install Certbot and obtain a certificate. Certbot will automatically update the Nginx config to listen on port 443 and redirect HTTP to HTTPS.
sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
Once TLS is active, set SECURE_SSL_REDIRECT=True and the other HTTPS security headers in your .env file. TrustRide’s settings already configure SECURE_HSTS_SECONDS, SECURE_HSTS_INCLUDE_SUBDOMAINS, and SECURE_HSTS_PRELOAD when DEBUG=False.
TrustRide ships with Sentry (sentry-sdk==2.63.0) in its dependencies. To enable error tracking, initialise Sentry in trust_ride/settings.py with your project DSN — for example, add sentry_sdk.init(dsn=os.getenv("SENTRY_DSN")) near the top of the file after installing sentry-sdk. See the Configuration reference for details.

Build docs developers (and LLMs) love