This is the new version of mybustimes https://mybustimes.cc
  • JavaScript 51.7%
  • Python 25%
  • HTML 16.6%
  • CSS 4.5%
  • SCSS 2.2%
Find a file
Kai fb1159e0e9 Enable TLS and disable SSL for email
Switch EMAIL_USE_TLS to True and EMAIL_USE_SSL to False so the app uses TLS (STARTTLS) instead of legacy SSL for SMTP connections. Aligns defaults with common mail server setups (e.g., port 587) while leaving host/port/credentials sourced from environment variables.
2026-05-05 05:40:02 +01:00
.github Add permissions to Docker build workflow 2025-12-11 02:00:03 +00:00
a Optimize DB queries and atomic updates 2026-02-13 04:36:03 +00:00
account Refactor subscription handling and template fixes 2026-04-22 17:20:06 +01:00
admin_dash Add DISABLE_JESS flag to disable Discord API 2026-04-15 09:57:11 +01:00
api Add API endpoint for for-sale vehicle count 2026-01-25 18:45:31 +00:00
apply tracking all model changes 2025-10-12 08:22:01 +01:00
docs updates 2025-09-12 17:00:01 +01:00
fleet Update timetable_add.html 2026-05-04 00:33:00 +01:00
forum Add DISABLE_JESS flag to disable Discord API 2026-04-15 09:57:11 +01:00
from updates 2025-09-21 11:44:57 +01:00
gameData Integrate S3 storage for static and media files 2025-11-28 04:35:42 +00:00
giveaway Optimize DB queries and atomic updates 2026-02-13 04:36:03 +00:00
group Optimize views/queries, caching and docs 2026-02-13 03:47:02 +00:00
main Add DISABLE_JESS flag to disable Discord API 2026-04-15 09:57:11 +01:00
media Improve JSON loading and import robustness 2026-02-16 23:51:15 +00:00
messaging Optimize views/queries, caching and docs 2026-02-13 03:47:02 +00:00
mybustimes Enable TLS and disable SSL for email 2026-05-05 05:40:02 +01:00
organisation updates 2025-08-25 23:50:02 +01:00
routes Add --clean-up to move_unused_routes 2026-03-05 22:21:54 +00:00
static Refactor favicon handling and add new theme CSS 2026-01-07 06:07:20 +00:00
staticfiles Update map tile URL and adjust layout spacing 2026-01-04 21:51:53 +00:00
tickets Add DISABLE_JESS flag to disable Discord API 2026-04-15 09:57:11 +01:00
tracking Return comparable tuples from alphanum_key 2026-04-01 19:57:00 +01:00
wiki Refactor ad container markup across templates 2026-01-27 13:27:50 +00:00
words Add DISABLE_JESS flag to disable Discord API 2026-04-15 09:57:11 +01:00
._.gitignore Update 2025-07-07 01:12:27 +01:00
._readme.md Update 2025-07-07 01:12:27 +01:00
._requirements.txt fixes 2025-07-07 16:41:53 +01:00
.DS_Store Add forum management UI and resync workers 2026-02-21 17:23:57 +00:00
.gitattributes Apply .gitignore and untrack ignored files 2025-07-06 19:01:50 +01:00
.gitignore updates 2025-09-21 10:15:54 +01:00
.gitmodules Replace display submodule with local templates 2025-12-14 15:15:13 +00:00
1.4.0 Update user activity template and aiosignal version 2025-11-12 01:57:02 +00:00
compose.yaml Add live activity and user actions admin views 2025-12-31 17:25:43 +00:00
css-gradients.md Update table of contents for CSS gradients guide 2026-03-12 18:05:49 +00:00
data.json Update stop names URLs for add/edit routes 2025-12-24 19:34:40 +00:00
Dockerfile Create Dockerfile 2026-03-08 07:24:59 +00:00
index.html Change title and enhance CSS styles 2026-02-14 11:20:56 +00:00
initial_data.json Patch 2025-07-15 18:46:06 +01:00
licence.md Fix formatting of Section 6 header in licence.md 2025-10-06 11:51:35 +01:00
manage.py Apply .gitignore and untrack ignored files 2025-07-06 19:01:50 +01:00
migrate.sh Apply .gitignore and untrack ignored files 2025-07-06 19:01:50 +01:00
package-lock.json Add admin_logs and search_fleet_history commands 2026-03-12 10:29:18 +00:00
quick_diagnosis.py Refactor theme context, caching, and ban checks 2026-02-02 19:35:40 +00:00
readme.md Revise database setup instructions in README 2026-04-14 19:06:05 +01:00
requirements.txt Downgrade PyJWT from 2.12.0 to 2.9.0 2026-03-16 01:00:19 +00:00
scraper.py update bustimes import 2025-07-16 12:39:30 +01:00

MyBusTimes

License: CC BY-NC-SA 4.0 CodeRabbit Pull Request Reviews

MyBusTimes is a Django-based platform for bus route data, live tracking, community features, and admin workflows. This repository includes the web app, API endpoints, admin dashboards, and supporting services.

Table of Contents

  • Overview
  • Tech Stack
  • Requirements
  • Quick Start (Local)
  • Environment Variables
  • Database Setup (Local Postgres)
  • Running the App
  • Production Notes
  • Optional: Docker Compose (Sanitized)
  • Nginx Reference
  • Troubleshooting

Overview

  • Public-facing site, community content, and documentation.
  • Admin tools for moderation, data imports, and analytics.
  • API endpoints for routes, stops, timetables, and tracking.

Tech Stack

  • Python / Django (ASGI)
  • Django REST Framework
  • PostgreSQL (recommended) or SQLite (local dev)
  • Optional: PgBouncer for DB pooling

Requirements

  • Python 3.11.x
  • pip
  • PostgreSQL 17.x (optional for local, recommended for staging/prod)

Quick Start (Local)

Create a virtual environment and run with SQLite:

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python manage.py migrate
python manage.py loaddata data.json
python manage.py createsuperuser
python manage.py runserver

App will be available at http://localhost:8000

Environment Variables

Create a .env file with at least these values. Use real secrets locally and in prod.

DEBUG=True
SECRET_KEY=
ALLOWED_HOSTS=

DB_NAME=mybustimes
DB_USER=
DB_PASSWORD=
DB_HOST=
DB_PORT=

CF_SITE_KEY=
CF_SECRET_KEY=

STRIPE_SECRET_KEY=
STRIPE_PUBLISHABLE_KEY=
STRIPE_WEBHOOK_SECRET=
STRIPE_BILLING_PORTAL_URL=https://billing.stripe.com/

STRIPE_PUBLISHABLE_KEY_TEST=
STRIPE_SECRET_KEY_TEST=
STRIPE_WEBHOOK_SECRET_TEST=

STRIPE_BASIC_MONTHLY_PRICE_ID=
STRIPE_BASIC_YEARLY_PRICE_ID=
STRIPE_BASIC_ONE_OFF_PRICE_ID=
STRIPE_PRO_MONTHLY_PRICE_ID=
STRIPE_PRO_YEARLY_PRICE_ID=
STRIPE_PRO_ONE_OFF_PRICE_ID=

DISCORD_BOT_API_URL=http://localhost:8070
DISCORD_WEB_ERROR_WEBHOOK=
DISCORD_404_ERROR_WEBHOOK=
DISCORD_REPORTS_CHANNEL_ID=
DISCORD_LIVERY_ID=
DISCORD_GAME_ID=
DISCORD_OPERATOR_LOGS_ID=
DISCORD_GUILD_ID=
DISCORD_BOT_API_TOKEN=

SMTP_HOST=
SMTP_PORT=
SMTP_USER=
SMTP_PASSWORD=

Notes:

  • Add your domain to CSRF_TRUSTED_ORIGINS in settings.
  • Keep DEBUG=True in local dev to bypass captcha checks.

Database Setup (Local)

To run MBT local you can use sqlite

settings_local.py

from pathlib import Path

BASE_DIR = Path(__file__).resolve().parent.parent

DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.sqlite3",
        "NAME": BASE_DIR / "db.sqlite3",
    }
}

If you prefer PostgreSQL locally:

```bash
sudo apt update
sudo apt install postgresql postgresql-contrib -y
sudo systemctl enable postgresql
sudo systemctl start postgresql

Create DB and user:

sudo -i -u postgres
psql
CREATE USER mybustimesdb WITH PASSWORD 'your_secure_password';
CREATE DATABASE mybustimes OWNER mybustimesdb;
GRANT ALL ON SCHEMA public TO mybustimesdb;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO mybustimesdb;
\q

Then set DB_* in .env and run migrations.

Running the App

With your venv active:

python manage.py migrate
python manage.py loaddata data.json
python manage.py runserver

Production Notes

  • Set DEBUG=False and configure ALLOWED_HOSTS.
  • Use PostgreSQL.
  • Use a reverse proxy (Nginx) in front of ASGI workers.
  • Production DB architecture documented internally.

Optional: Docker Compose (Sanitized)

This is an example snippet to illustrate pooling and health checks. Use your own values.

services:
  pgbouncer:
    image: edoburu/pgbouncer:1.23.1
    restart: always
    environment:
      DB_USER:
      DB_PASSWORD:
      DB_HOST: pg17
      DB_NAME:
      POOL_MODE: transaction
      MAX_CLIENT_CONN: 500
      DEFAULT_POOL_SIZE: 32
    ports:
      - "6432:5432"
    depends_on:
      - pg17
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -h pg17 -p 5432 -U ${DB_USER}"]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 10s
    deploy:
      resources:
        limits:
          cpus: '0.50'
          memory: 512M
        reservations:
          cpus: '0.25'
          memory: 256M
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "3"

  pg17:
    image: postgres:17.2
    shm_size: 2g
    env_file:
      - .env
    command:
      - "postgres"
      - "-c"
      - "max_connections=150"
      - "-c"
      - "shared_buffers=4GB"
      - "-c"
      - "effective_cache_size=12GB"
      - "-c"
      - "maintenance_work_mem=1GB"
      - "-c"
      - "checkpoint_completion_target=0.9"
      - "-c"
      - "wal_buffers=16MB"
      - "-c"
      - "default_statistics_target=100"
      - "-c"
      - "random_page_cost=1.1"
      - "-c"
      - "effective_io_concurrency=200"
      - "-c"
      - "work_mem=32MB"
      - "-c"
      - "huge_pages=off"
      - "-c"
      - "min_wal_size=1GB"
      - "-c"
      - "max_wal_size=4GB"
    ports:
      - "127.0.0.1:5432:5432"
    volumes:
      - pg17-data:/var/lib/postgresql/data
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres}"]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 10s
    deploy:
      resources:
        limits:
          cpus: '2.00'
          memory: 6G
        reservations:
          cpus: '1.00'
          memory: 3G
    logging:
      driver: json-file
      options:
        max-size: "50m"
        max-file: "5"

volumes:
  pg17-data:

Nginx Reference

Minimal reverse proxy example:

server {
    listen 4986;
    server_name example.com;

    client_max_body_size 1G;

    location /static/ {
        alias /srv/MyBusTimes/staticfiles/;
        autoindex off;
    }

    location /media/ {
        alias /srv/MyBusTimes/media/;
        autoindex off;
    }

    location / {
        proxy_pass http://127.0.0.1:5681;
        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;
    }
}

Troubleshooting

  • If CSS or media is missing, run python manage.py collectstatic and verify file permissions.
  • If DB connection fails, confirm .env values and Postgres user permissions.