Cloud Deployment Infrastructure#
Overview#
StudentHub's production infrastructure is split across two platforms:
- AWS EC2 — hosts the monolithic Yii2/PHP backend (
studenthub) running under Apache - Railway — hosts containerized microservices (
studenthub-microservices) and the Railway-targeted build of the main PHP app
AWS EC2 — Apache/PHP Backend#
The aws-template.sh bootstrap script automates full EC2 provisioning. Key steps:
- PHP & Apache setup: Installs PHP 7.4 and Apache2 via the
ondrej/phpPPA - Codebase clone: Pulls
studenthubfrom GitHub via SSH deploy key into/var/www/html/studenthub - Application init: Runs
./init --env=Productionand./yii migratefor DB migrations - Virtual hosts: Creates separate Apache VirtualHost configs for each API subdomain :
v.studenthub.co→ verification appinspector.api.studenthub.co→ inspector appstatus.api.studenthub.co→ status appemployer.api.studenthub.co→ company/employer appstudent.api.studenthub.co→ candidate appstaff.api.studenthub.co→ staff appadmin.api.studenthub.co→ admin app
- SSL: Enables
mod_ssl,mod_rewrite, andmod_headers; each VirtualHost has both port 80 and 443 blocks - Cron: Installs the app's crontab from
cron/cronlist
Railway Platform — Containerized Services#
Main PHP App on Railway#
The studenthub backend also ships two Railway-specific Dockerfiles for containerized deployment:
- Production:
Dockerfile-nginx-railway— runs./init --env=Production-Railwayand usesnginx/railway-prod.conf - Development:
Dockerfile-nginx-dev-railway— runs./init --env=Dev-Server-Railwayand usesnginx/railway-dev.conf
Both images use PHP 8.2-FPM + Nginx and run Composer install, DB migrations, and cron on startup. The active Dockerfile is selected via the Railway environment variable RAILWAY_DOCKERFILE_PATH .
Railway MySQL databases are accessible via Railway CLI: railway connect mysql and railway connect mysql-wallet .
Microservices on Railway#
The studenthub-microservices mono-repo contains six services, each with its own Dockerfile:
| Service | Language | Purpose |
|---|---|---|
SQS | Node.js | AWS SQS event consumer |
linear | TypeScript | Linear integration |
process-id-request | Go | ID request processing with cron jobs |
proxy-manager | Nginx | Internal reverse proxy |
yeastar-voicemails | Node.js | Yeastar PBX voicemail sync |
yeastar-websocket-client | Node.js | Yeastar WebSocket client |
Inter-service communication uses Railway's internal DNS pattern {service}.railway.internal:{port} . The Nginx proxy-manager routes public traffic to each internal service:
/bawes-doc-updater/→doc-updater.railway.internal:3003/linear/→linear.railway.internal:3002/yeastar-voicemails/→yeastar-voicemails.railway.internal:3001
The proxy-manager docker-compose.yml also mirrors this topology locally for development, using a shared microservices_network bridge .
AWS S3 Integration#
S3 access is handled by the S3ResourceManager component and the authentication method differs by deployment:
- EC2 (traditional): Uses
AUTH_VIA_IAM_ROLE— no credentials in code - Railway: Uses
AUTH_VIA_KEY_AND_SECRETwith credentials injected as Railway environment variables (AWS_MEDIACONVERT_RAILWAY_ACCESS_KEY_ID,AWS_MEDIACONVERT_RAILWAY_SECRET_ACCESS_KEY)
Production bucket: studenthub-uploads. Dev-server Railway bucket: studenthub-uploads-dev-server .
Sentry Error Monitoring#
Sentry is integrated via the notamedia\sentry\SentryTarget log target across all environments. Configuration strategy differs by platform:
- EC2 / traditional environments: DSN and environment label are hardcoded in the relevant
environments/*/common/config/main-local.phpfile — see prod config and dev-server config - Railway environments: DSN and settings are injected via environment variables
SENTRY_DSN,SENTRY_ENVIRONMENT, andSENTRY_TRACES_SAMPLE_RATE
Architecture Diagram#
Key Files & References#
| File | Purpose |
|---|---|
aws-template.sh | Full EC2 server bootstrap script |
railway/railway.md | Railway CLI usage and Dockerfile env var |
proxy-manager/docker-compose.yml | Local dev topology mirroring Railway network |
Dockerfile-nginx-railway | Production Railway Docker build |
Dockerfile-nginx-dev-railway | Dev Railway Docker build |
environments/prod-railway/common/config/main-local.php | Railway prod env config (S3, Sentry via env vars) |