Skip to content

๐Ÿ’ป Developer Guide

๐ŸŸข New here? Start with the Setup Guide to get your environment running quickly.

This guide is for developers who want to contribute to or extend the Edmonton Accident & Near Miss Reporting Platform.


๐Ÿ› ๏ธ Prerequisites

  • PHP 8.2+
  • MySQL 8+
  • Node.js (for frontend build tasks, optional)
  • Composer (if using additional PHP libraries)
  • Python 3 (if working with MkDocs documentation)

โš™๏ธ Setting Up Locally

  1. Clone the repository:
git clone https://github.com/ChadOhman/opensafetymap.git
cd accident-reports
  1. Import the database:
mysql -u your_user -p accidents < seed.sql
  1. Configure database in .env:
DB_HOST=localhost
DB_NAME=accidents
DB_USER=root
DB_PASS=secret
  1. Start PHP local server:
php -S localhost:8000 -t public
  1. Open http://localhost:8000 in your browser.

๐Ÿ“‚ Codebase Structure

accident-reports/
โ”œโ”€โ”€ api/               # Backend PHP APIs
โ”‚   โ”œโ”€โ”€ auth/          # OAuth endpoints
โ”‚   โ”œโ”€โ”€ reports/       # Report submission & management
โ”‚   โ”œโ”€โ”€ moderation/    # Moderation actions
โ”‚   โ”œโ”€โ”€ analytics/     # Analytics data endpoints
โ”‚   โ””โ”€โ”€ users/         # User management
โ”œโ”€โ”€ db/                # Database helpers & connection
โ”œโ”€โ”€ public/            # Frontend HTML/JS/CSS
โ”‚   โ”œโ”€โ”€ index.html     # Map & reports
โ”‚   โ”œโ”€โ”€ moderation_dashboard.html
โ”‚   โ””โ”€โ”€ js/            # JS modules
โ”œโ”€โ”€ docs/              # Documentation site (MkDocs)
โ”œโ”€โ”€ seed.sql           # Schema + seed data
โ”œโ”€โ”€ .env.example       # Example environment file
โ”œโ”€โ”€ mkdocs.yml         # Documentation config
โ””โ”€โ”€ .github/           # GitHub workflows & templates

๐Ÿ”Œ APIs

  • All API endpoints are under /api/.
  • Example: GET /api/reports/list.php
  • Authentication uses OAuth tokens mapped to local user accounts.

๐Ÿ”’ Security Notes

  • Always use prepared statements for DB queries.
  • Never commit real .env credentials.
  • Validate file uploads (S3).
  • Sanitize user inputs to prevent XSS.

๐Ÿš€ Extending the Platform

  • Add new API endpoints in /api/
  • Add frontend modules in /public/js/
  • Update database schema via migration (then update seed.sql)
  • Document changes in CHANGELOG.md and ROADMAP.md

๐Ÿงช Testing

  • Test APIs with Postman or curl.
  • Use seeded data (seed.sql) for dev testing.
  • CI/CD workflow runs PHP lint + SQL validation.

๐Ÿ“– Documentation

  • Docs are written in Markdown under /docs/.
  • Serve locally with:
mkdocs serve
  • Deploy with:
mkdocs gh-deploy

Happy hacking! ๐Ÿฅท