Docs

// architecture, setup, API

Architecture

┌──────────────┐ ┌────────────────────────────────────┐ │ Browser │────────────────────────────────────│ │ (Vanilla JS)│ │ Apache + PHP │ │ │ │ Auth · API · Scrapers │ └──────────────┘ └────────────────────────────────────┘ │ │ ┌─────────────────┐ │ MySQL 8.0 │ │ + spatial index │ └─────────────────┘

Tech Stack

Vanilla JSES Modules
PHP 8.3API Layer
MySQL 8.0Spatial Index
Google OAuthServer-Side
ApacheRewrites + Cache
OSM OverpassOrg Discovery
Web PushVAPID
PWAOffline

Quick Start

Clone the repo
git clone https://github.com/YOUR_USERNAME/tenantunion.git
Set up MySQL
MySQL 8.0+, then mysql -u root tenantunion < sql/schema.sql
Configure secrets
Copy .env.example to .env and fill in DB + Google OAuth credentials.
Configure Apache
Enable mod_rewrite, mod_php. Point DocumentRoot at the repo dir.
Schedule scrapers
Cron: 0 4 * * 1 /usr/bin/php /var/www/tenantunion/api/scrapers/refresh-orgs.php

PHP API Endpoints

EndpointMethodPurpose
/api/auth/google.phpGETStart Google OAuth flow
/api/auth/callback.phpGETOAuth callback — create session
/api/auth/me.phpGETCurrent authenticated user
/api/auth/logout.phpPOSTDestroy session
/api/nearby.phpGETSpatial search — tenant unions near lat/lng
/api/union.phpGETUnion detail (members, contact, supported reports)
/api/unions.phpGET/POSTList by city / create new union
/api/landlord.phpGETLandlord detail with slumlord score
/api/landlords.phpGET/POSTRanked landlords / create new
/api/building.phpGETBuilding detail
/api/buildings.phpGET/POSTBuildings by landlord / create
/api/reports.phpPOSTSubmit a report (with optional inline landlord/building creation)
/api/report.phpGETSingle report detail
/api/confirm.phpPOSTConfirm a report
/api/flag.phpPOSTFlag a report
/api/join.phpPOST/DELETEJoin / leave a tenant union
/api/profile.phpGET/POSTProfile + stats / update
/api/leaderboard.phpGETTop organizers
/api/alerts.phpGET/POST/DELETESubscribe to landlord/union updates
/api/push.phpPOST/DELETEWeb Push subscription
/api/networks.phpGETList tenant union networks
/api/scan-area.phpPOSTTrigger OSM scan for new unions in an area
/api/og-share.phpGETOG meta for shared union/landlord links
/api/investor.phpPOSTFunder contact form (3/day/IP)
/api/admin/*.phpGET/POSTModeration dashboard (auth-gated)

Slumlord Score Formula

Each landlord gets a 0–100 composite score recomputed on every page load:

  reports        × 2
+ severity_sum   × 3
+ reporters      × 5
+ has_eviction      ? 20 : 0
+ has_retaliation   ? 15 : 0
+ has_habitability  ? 10 : 0
+ has_deposit_theft ?  8 : 0
→ capped at 100

Try it on the score calculator.