๐ป 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
- Clone the repository:
git clone https://github.com/ChadOhman/opensafetymap.git
cd accident-reports
- Import the database:
mysql -u your_user -p accidents < seed.sql
- Configure database in
.env:
DB_HOST=localhost
DB_NAME=accidents
DB_USER=root
DB_PASS=secret
- Start PHP local server:
php -S localhost:8000 -t public
- Open
http://localhost:8000in 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
.envcredentials. - 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.mdandROADMAP.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! ๐ฅท