How ruthwik2/event-media-platform works
Purpose and Runtime Topology
A full-stack event-photography platform: events contain albums, albums contain photo/video media; users discover, share, moderate, and engage with content. It runs as a Next.js frontend, Express API/Socket.IO server, and PostgreSQL database, containerized together via docker-compose.yml. Core backend entry point: backend/src/app.js; frontend App Router root: frontend/src/app/layout.tsx.
Web Client and Navigation
The Next.js 14 client separates unauthenticated and protected experiences through route groups, with a shared main layout/navigation. Major workflows include gallery/search, media detail, uploads, event/album management, sharing, profiles, notifications, and admin approval queues.
Paths: frontend/src/app/(auth)/layout.tsx, frontend/src/app/(main)/layout.tsx, frontend/src/app/(main)/events/[id]/page.tsx.
API Composition and Authorization Boundary
Express mounts resource routers below /api for auth, events, albums, media, notifications, and club settings. Controllers implement resource workflows; JWT middleware authenticates requests and enforces role/access rules. Roles include admin, photographer, club member, and viewer, with additional private-content and collaborator/access-request controls.
Paths: backend/src/app.js, backend/src/middleware/auth.js, backend/src/routes/mediaRoutes.js.
Persistent Domain Model
Prisma/PostgreSQL is the source of truth for users, events, albums, media, social interactions, tags, notifications, access requests, and club settings. The central hierarchy is Event → Album → Media; media also connects to face metadata, AI labels/captions, moderation state, and user interactions. Schema migrations evolve approval, sharing, privacy, tag positioning, categories, and moderation.
Paths: backend/prisma/schema.prisma, backend/prisma/migrations/20260602000000_add_access_requests/migration.sql, backend/prisma/seed.js.
Media Ingestion and Delivery Pipeline
Bulk uploads enter through Multer middleware, then media controllers coordinate persistence and derived processing. sharp creates thumbnails/compressed output and composites SVG watermarks for downloads. Storage is a deployment boundary: local disk by default or AWS S3 when enabled. Media capabilities include search, favourites, tagging, comments, likes, download tracking, and visibility-aware delivery.
Paths: backend/src/middleware/upload.js, backend/src/controllers/mediaController.js, backend/src/services/imageService.js.
AWS Intelligence Pipeline
When S3/AWS are configured, uploaded images are analyzed through Rekognition for face indexing/search, labels, automatic captions, and content moderation. A user selfie establishes a Rekognition face identity; “My Photos” queries matching indexed media. Without S3/AWS credentials, this enrichment path is intentionally skipped rather than emulated.
Paths: backend/src/services/rekognitionService.js, backend/src/services/s3Service.js, backend/src/config/aws.js.
Sharing, Notifications, and Realtime
Events and albums expose guest-access paths via QR codes and share tokens, separate from authenticated API access. Tags, likes, comments, and approvals create notifications, delivered live through Socket.IO and represented in frontend Zustand state. The client establishes its realtime connection through a dedicated hook.
Paths: backend/src/services/notificationService.js, backend/src/config/socket.js, frontend/src/hooks/useSocket.tsx.
Deployment and External Dependencies
Docker orchestration provisions Postgres, backend, and frontend; backend configuration covers database, AWS, sockets, and logging. Browser API access is through the Axios client, while API CORS and Socket.IO depend on frontend/backend URLs. Material external services are PostgreSQL, optional AWS S3, and AWS Rekognition.
Paths: docker-compose.yml, backend/src/config/database.js, frontend/src/lib/axios.ts.
Main entry points: schema.prisma Domain Database · mediaController.js Media Workflow · app.js API Application · docker-compose.yml Docker Compose
Components 20
Next.js Client
- Auth Routes · Unauthenticated client experience.
frontend/src/app/(auth)/layout.tsx - Main App Routes · Protected navigation and application shell.
frontend/src/app/(main)/layout.tsx - Event Gallery
frontend/src/app/(main)/events/[id]/page.tsx - API Client
frontend/src/lib/axios.ts - Realtime Hook · Updates client notification state live.
frontend/src/hooks/useSocket.tsx
Express API
- API Application · Mounts API routers and initializes realtime transport.
backend/src/app.js - JWT Access Control · Authenticates users and enforces roles and private-content access.
backend/src/middleware/auth.js - Media API · Media discovery, engagement, delivery, and upload endpoints.
backend/src/routes/mediaRoutes.js
Media Pipeline
- Upload Middleware
backend/src/middleware/upload.js - Media Workflow · Coordinates media persistence, visibility, and derived processing.
backend/src/controllers/mediaController.js - Image Processing · Creates derivatives and watermarked downloads.
backend/src/services/imageService.js - Media Storage · Uses local storage by default or S3 when configured.
backend/src/services/s3Service.js
Data & Realtime
- Notification Service · Creates notifications from tags, engagement, and approvals.
backend/src/services/notificationService.js - Socket Gateway
backend/src/config/socket.js - Domain Database · Source of truth for users, Event → Album → Media, interactions, access, and settings.
backend/prisma/schema.prisma - Database Seed
backend/prisma/seed.js
Infrastructure & AWS
- Docker Compose · Runs frontend, backend, and Postgres together.
docker-compose.yml - AWS Rekognition · Indexes faces and enriches images with labels, captions, and moderation.
backend/src/services/rekognitionService.js - AWS Configuration · Enables S3 and Rekognition only when credentials are configured.
backend/src/config/aws.js - Database Configuration
backend/src/config/database.js
Connections 24
- Docker Compose → Main App Routes: runs
- Docker Compose → API Application: runs
- Docker Compose → Domain Database: provisions
- Auth Routes → API Client: auth requests
- Main App Routes → Event Gallery: hosts
- Main App Routes → API Client: uses
- API Client → API Application: HTTP /api
- Realtime Hook → Socket Gateway: Socket.IO
- API Application → JWT Access Control: applies
- API Application → Media API: mounts
- Media API → Upload Middleware: bulk upload
- Upload Middleware → Media Workflow: passes files
- Media Workflow → Image Processing: creates derivatives
- Media Workflow → Media Storage: stores and serves
- Media Workflow → Domain Database: persists metadata
- Media Workflow → AWS Rekognition: optional enrichment
- AWS Configuration → Media Storage: enables S3
- AWS Configuration → AWS Rekognition: enables
- AWS Rekognition → Domain Database: face and AI metadata
- API Application → Notification Service: engagement events
- Notification Service → Domain Database: persists
- Notification Service → Socket Gateway: emits live updates
- Database Configuration → Domain Database: connects
- Database Seed → Domain Database: populates