A native, self-hosted media community framework. Built as a containerized Node.js/Express API on Postgres + PostGIS, designed to run on AWS ECS Fargate with full ownership of data and event stream.
Covers five feature areas:
- Feeds — org-wide and per-group posts with comments and cursor pagination
- Groups — public/private groups, membership, moderators
- Resources — geolocated resources with PostGIS radius search (find resources within N meters, sorted by distance)
- Events — scheduling with RSVPs and location
- Messaging — conversations with a REST fallback and a real-time WebSocket channel
Everything bespoke flows from one idea: a row in user_entitlements says "this user may access this object" (a group, resource, track, or event). The referral code, the milestone engine, and manual admin/mentor grants are just three ways of writing those rows. Every surface — feed, library, map, calendar — filters by what the user is entitled to.
- Visibility: groups and resources are
public(everyone in the org),private(entitled, but listable), orsecret(invisible unless entitled). - Referral codes (
/api/codes): an admin builds a code with a bundle of grants (the dropdown). On/redeem, the whole bundle is applied to the new user and group memberships auto-created, so they land already curated. - Auto-graduation (
/api/profiles/milestones/:id/complete): completing a milestone grants its configured objects and awards a badge — no manual step. - Curated feed (
/api/feeds): merges org-wide announcements with posts from every entitled group;/carouselreturns the user's group thumbnails for the top bar;?group_id=shows a single group. Posts carryattachments_jsondeep links, can be liked, and/shareposts them into a DM while recording the source inpost_shares. - Resources (
/api/resources): list is entitlement-filtered;?on_map=truepowers the GIS layer;/:id/openverifies access, logs the view, and flagsopen_in_app_playerfor authenticated third-party links (wire to S3 presign / partner SSO in prod). - Profiles & transcript (
/api/profiles):/mereturns bio, badges, goals, saved resources, posting history, and track progress./:userId/transcript(admin/mentor) returns the full journey log plus rolled-up performance metrics — the resume/transcript export. - Journey transcript (
journey_events): every meaningful action (post, view, RSVP, message, share, badge, milestone, redeem) is logged through one service. This is the spine for both bespoke mentorship and KPI measurement.
Phase 2 schema lives in src/db/schema_phase2.sql and runs automatically after the base schema.
src/
server.js Express app + WebSocket server + health check
db/
pool.js Postgres connection pool (RDS-ready, SSL aware)
schema.sql Full schema, PostGIS + pgcrypto
migrate.js Migration runner (npm run migrate)
middleware/
auth.js JWT signing, auth guard, role guard
routes/
auth.js register / login
groups.js CRUD + join/leave
feeds.js posts + comments
resources.js geolocated CRUD + radius search
events.js events + RSVP
messages.js conversations + messages
Dockerfile
docker-compose.yml Local dev: API + PostGIS
infra/
task-definition.json ECS Fargate task definition template
cp .env.example .env
docker compose up --buildThe compose file runs migrations on startup. API is at http://localhost:8080, health at /health.
Quick smoke test:
# Register
curl -s localhost:8080/api/auth/register \
-H 'content-type: application/json' \
-d '{"email":"a@b.com","password":"password123","display_name":"Ada"}'
# Use the returned token
TOKEN=...
curl -s localhost:8080/api/feeds -H "authorization: Bearer $TOKEN" \
-H 'content-type: application/json' -d '{"body":"hello world"}'- Database — provision an RDS Postgres instance and enable PostGIS:
CREATE EXTENSION postgis;then runsrc/db/schema.sqlagainst it. - Build & push image to ECR:
aws ecr create-repository --repository-name community-platform docker build -t community-platform . docker tag community-platform:latest <ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com/community-platform:latest aws ecr get-login-password | docker login --username AWS --password-stdin <ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com docker push <ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com/community-platform:latest
- Secrets — store
DB_PASSWORDandJWT_SECRETin Secrets Manager,DB_HOST/DB_USERin SSM Parameter Store. - Task definition — fill in the placeholders in
infra/task-definition.jsonand register it. - Service — create an ECS service behind an Application Load Balancer. Point the target group health check at
/health. The ALB must allow WebSocket upgrades (it does by default) for the/wspath.
- The WebSocket fan-out uses an in-memory socket map, which only works within a single task. To scale messaging across multiple Fargate tasks, replace it with Redis pub/sub via ElastiCache: each task subscribes to a channel and re-broadcasts to its own connected sockets.
- Put media uploads on S3 rather than the database; store only the object key in
resources/posts. - For KPI measurement, have each route emit an event (post created, RSVP, message sent, resource viewed) to a stream — Kinesis Firehose into S3 or directly into a warehouse — so analytics never touch the production DB.
- Rotate
JWT_SECRET, never commit.env - Run the container as non-root (already configured)
- Restrict the RDS security group to the ECS task security group only
- Add rate limiting (e.g.
express-rate-limit) and request validation on every route - Add refresh tokens / token revocation if sessions need to be invalidated