Skip to content

TransitTracker/backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Backend for Transit Tracker

This repository contains the backend services for Transit Tracker. The server is powered by a Laravel application (PHP). The main application is hosted in the frontend repository (a NuxtJS app), but some frontend parts are hosted here (will be detailled below).

Parts

  • Developper home page
  • API : currently V2, V2.1 coming soon
  • exo VIN Project: a collaborative effort to associate VIN numbers to fleet numbers. exo GTFS-RT feeds only include the Vehicule Identification Number (VIN) as a Vehicule ID.
  • Admin panel (with Filament)

Services

The backend services use multiple services, some hosted on the same server and other hosted elsewere. Where possible, a local installation is preffered.

For local developpement, only a small portion of those services are necessary to run the base application. Optional service might throw an error, but can be ignored.

MySQL

Required.

SQLite can work, but some migrations will not run. MySQL is the recommended way to go.

Redis

Required.

Used for caching and job management (through Horizon).

Horizon

Mandatory, but can be replaced with php artisan queue:work

Laravel Horizon is the services use to manage the queues where long running jobs are running.

To start the service, run php artisan horizon

The following queue are used (a redesign is coming):

  • realtime-download Realtime data fetching
  • realtime-process Realtime data processing
  • notifications All notifications
  • static Static data update (download and processing)
  • ohdear Jobs related to the OhDear monitoring service
  • default All others jobs

Websockets

Optional.

Used for frontend automatic realtime refresh. Using Beyond Code Laravel Websockets.

Slack

Optional.

Used for admin notifications about late jobs and invalid static data.

OhDear

Optional.

Used for monitoring on production, everything running well.

Cloudflare Turnstile

Optional.

Used for VIN suggestion human validation. Bypassed on local.

print-gtfs-rt-cli

Optional.

Used for some GTFS-RT feeds that do not work with the PHP implementation (so far, Zenbus feeds).

Run the server

Requirements

  1. composer install
  2. cp .env.example .env check the settings and make sure to create a database
  3. php artisan key:generate
  4. php artisan migrate
  5. php artisan horizon:publish
  6. yarn install
  7. php artisan tinker then create a user
    1. User::create(['name' => 'Admin', 'email' => 'admin@example.org', 'password' => bcrypt('password')]);
    2. Don’t forget to adjust the .env variables, MAIL_TO
  8. Go to /admin and create a region and an agency to get started

Commands to run the server

One process each.

  1. yarn dev
  2. php artisan serve
  3. php artisan horizon
  4. php artisan websocket:serve

Current deploy script

For production environnement.

php artisan migrate --force

yarn install
yarn build

php artisan config:cache
php artisan event:cache
php artisan horizon:terminate
php artisan horizon:publish
php artisan log-viewer:publish
php artisan icons:cache
php artisan route:cache
php artisan schedule-monitor:sync
php artisan view:cache
php artisan websockets:restart