A secure, scalable platform for content creators to monetize their work through subscriptions, pay-per-view content, and direct fan engagement.
- Multi-tier Subscriptions: FREE, BASIC, PREMIUM, VIP tiers with custom pricing
- Content Management: Upload images, videos, and files with automatic processing
- Pay-Per-View Content: Monetize exclusive content beyond subscriptions
- Real-time Messaging: Direct communication with subscribers via WebSocket
- Analytics Dashboard: Track earnings, subscriber growth, and content performance with interactive charts
- Automated Payouts: Stripe Connect integration with automatic transfers
- 2FA Security: TOTP-based two-factor authentication
- Content Feed: Browse and discover creator content with filtering
- Subscription Management: Easy subscription and tier management interface
- Secure Payments: Stripe-powered payment processing
- Real-time Chat: Direct messaging with favorite creators
- Personalized Feed: Content filtered by active subscriptions
- Monorepo Architecture: Turborepo with NestJS backend and Next.js frontend
- Real-time Communication: Socket.io for instant messaging and notifications
- Media Processing: Automatic image optimization (Sharp) and video transcoding (FFmpeg)
- Secure Storage: S3/MinIO with server-side encryption (AES-256)
- Caching Layer: Redis for sessions, rate limiting, and job queues
- Type Safety: Full TypeScript coverage across frontend and backend
- E2E Testing: Comprehensive Playwright tests for critical user flows
- Production Ready: Complete AWS infrastructure with Terraform
- NestJS 10: Progressive Node.js framework
- PostgreSQL 15: Primary database with Prisma ORM (18 tables)
- Redis 7: Caching, sessions, and message queue (Bull)
- Stripe Connect: Payment processing and automated payouts
- Sharp & FFmpeg: Media processing and optimization
- Socket.io: Real-time bidirectional communication
- JWT: Authentication with refresh token rotation
- Next.js 14: React framework with App Router
- React Query (TanStack): Server state management and caching
- Zustand: Client state management
- TailwindCSS: Utility-first CSS framework
- Shadcn/ui: Accessible React component library
- Recharts: Data visualization and analytics charts
- Socket.io Client: Real-time features
- date-fns: Date manipulation and formatting
- Docker & Docker Compose: Containerization
- AWS ECS Fargate: Serverless container orchestration
- Terraform: Infrastructure as Code with modular architecture
- GitHub Actions: CI/CD pipeline with automated testing
- CloudFront: Global CDN for media delivery
- Application Load Balancer: HTTPS termination and traffic distribution
- CloudWatch: Logging, monitoring, and alerting
ofm/
├── apps/
│ ├── api/ # NestJS backend
│ │ ├── src/
│ │ │ ├── auth/ # Authentication & 2FA (JWT + TOTP)
│ │ │ ├── users/ # User management (creators/subscribers)
│ │ │ ├── content/ # Content management & feed
│ │ │ ├── media/ # Media upload & processing
│ │ │ │ ├── processors/ # Sharp (images) & FFmpeg (videos)
│ │ │ │ └── storage/ # S3/MinIO integration
│ │ │ ├── payments/ # Stripe Connect & payouts
│ │ │ ├── subscriptions/ # Multi-tier subscription logic
│ │ │ ├── messaging/ # Real-time messaging (WebSocket)
│ │ │ │ ├── messaging.gateway.ts
│ │ │ │ ├── messaging.service.ts
│ │ │ │ └── messaging.controller.ts
│ │ │ └── common/
│ │ │ └── database/ # Prisma service
│ │ ├── prisma/
│ │ │ └── schema.prisma # Database schema (18 tables)
│ │ ├── Dockerfile.prod # Multi-stage production build
│ │ └── package.json
│ │
│ └── web/ # Next.js 14 frontend
│ ├── app/
│ │ ├── (auth)/ # Authentication pages
│ │ │ ├── login/
│ │ │ └── register/
│ │ └── (app)/ # Authenticated pages
│ │ ├── creator/ # Creator-specific pages
│ │ │ ├── dashboard/ # Main dashboard with stats
│ │ │ ├── upload/ # Content upload interface
│ │ │ ├── analytics/ # Analytics with Recharts
│ │ │ └── subscriptions/ # Tier management
│ │ ├── feed/ # Subscriber content feed
│ │ ├── messages/ # Real-time messaging UI
│ │ └── subscriptions/ # Subscription discovery
│ ├── components/
│ │ ├── ui/ # Shadcn/ui components
│ │ └── navigation.tsx # Role-based navigation
│ ├── contexts/ # React contexts (auth, etc.)
│ ├── hooks/ # Custom hooks
│ │ └── use-socket.ts # Socket.io hook
│ ├── lib/
│ │ └── api.ts # API client with interceptors
│ ├── e2e/ # Playwright E2E tests
│ │ ├── fixtures/
│ │ ├── pages/ # Page Object Models
│ │ ├── auth.spec.ts
│ │ ├── creator-dashboard.spec.ts
│ │ ├── content-upload.spec.ts
│ │ └── subscriber-feed.spec.ts
│ ├── playwright.config.ts
│ ├── Dockerfile.prod # Multi-stage production build
│ └── package.json
│
├── terraform/ # Infrastructure as Code
│ ├── main.tf # Main configuration
│ ├── variables.tf # Input variables
│ ├── outputs.tf # Output values
│ └── modules/ # Terraform modules
│ ├── vpc/ # VPC with public/private subnets
│ ├── rds/ # PostgreSQL RDS
│ ├── elasticache/ # Redis cluster
│ ├── s3/ # S3 buckets with encryption
│ ├── cloudfront/ # CDN distribution
│ ├── ecs/ # ECS Fargate cluster
│ ├── alb/ # Application Load Balancer
│ ├── route53/ # DNS management
│ └── monitoring/ # CloudWatch dashboards
│
├── .github/
│ └── workflows/
│ └── ci-cd.yml # Complete CI/CD pipeline
│
├── docs/
│ ├── PHASE1_COMPLETE.md # Backend implementation docs
│ ├── DEPLOYMENT.md # Production deployment guide
│ └── COMPLETE_DEVELOPMENT_GUIDE.md # Full development guide
│
├── docker-compose.yml # Development environment
├── docker-compose.prod.yml # Production environment
├── turbo.json # Turborepo configuration
├── package.json # Root package.json
└── README.md # This file
- Node.js 20+
- Docker & Docker Compose
- PostgreSQL 15
- Redis 7
- Stripe account (test mode)
- Clone the repository
git clone https://github.com/yourusername/ofm.git
cd ofm- Install dependencies
npm install- Set up environment variables
# Backend (.env in apps/api/)
cp apps/api/.env.example apps/api/.env
# Frontend (.env.local in apps/web/)
cp apps/web/.env.example apps/web/.env.localEdit the files with your configuration.
- Start services with Docker Compose
docker-compose up -dThis starts:
- PostgreSQL on port 5432
- Redis on port 6379
- MinIO (S3-compatible) on ports 9000/9001
- MailHog (email testing) on port 8025
- Adminer (database UI) on port 8080
- Run database migrations
cd apps/api
npx prisma migrate dev
npx prisma db seed # Optional: seed test data- Start development servers
# In root directory
npm run dev
# Or individually
npm run dev:api # API on http://localhost:3001
npm run dev:web # Web on http://localhost:3000- Access the application
- Frontend: http://localhost:3000
- API: http://localhost:3001
- API Documentation: http://localhost:3001/api/docs
- MinIO Console: http://localhost:9001 (minioadmin/minioadmin)
- MailHog: http://localhost:8025
- Adminer: http://localhost:8080
# Development
npm run dev # Start all services with Turbo
npm run dev:api # Start API only
npm run dev:web # Start Web only
# Building
npm run build # Build all apps
npm run build:api # Build API
npm run build:web # Build Web
# Testing
npm run test # Run all tests
npm run test:api # Run API tests
npm run test:e2e # Run Playwright E2E tests
npm run test:e2e:ui # Run E2E tests with Playwright UI
npm run test:e2e:debug # Debug E2E tests
# Linting & Type Checking
npm run lint # Lint all code
npm run type-check # TypeScript type checking
# Database (Prisma)
npm run db:migrate # Run database migrations
npm run db:studio # Open Prisma Studio
npm run db:seed # Seed database with test data
npm run db:reset # Reset database (careful!)# Database
DATABASE_URL=postgresql://ofm:password@localhost:5432/ofm
# Redis
REDIS_URL=redis://localhost:6379
# JWT Secrets (generate with: openssl rand -base64 64)
JWT_SECRET=your-super-secret-jwt-key
JWT_REFRESH_SECRET=your-super-secret-refresh-key
# Stripe
STRIPE_SECRET_KEY=sk_test_xxx
STRIPE_WEBHOOK_SECRET=whsec_xxx
STRIPE_CONNECT_CLIENT_ID=ca_xxx
# S3/MinIO
AWS_ACCESS_KEY_ID=minioadmin
AWS_SECRET_ACCESS_KEY=minioadmin
AWS_REGION=eu-west-1
AWS_S3_BUCKET=ofm-media
S3_ENDPOINT=http://localhost:9000 # Remove for AWS S3
# Application
FRONTEND_URL=http://localhost:3000
PORT=3001
NODE_ENV=developmentNEXT_PUBLIC_API_URL=http://localhost:3001
NEXT_PUBLIC_APP_URL=http://localhost:3000# Run all tests
npm run test
# Run with coverage
npm run test:cov
# Watch mode
npm run test:watch# Install Playwright browsers (first time only)
npx playwright install
# Run all E2E tests
npm run test:e2e
# Run with Playwright UI (interactive)
npm run test:e2e:ui
# Debug mode
npm run test:e2e:debug
# Run specific test file
npx playwright test e2e/auth.spec.tsTest Coverage:
- Authentication (login, register, 2FA)
- Creator dashboard and navigation
- Content upload workflow
- Analytics dashboard
- Subscriptions management
- Subscriber feed and content viewing
- Real-time messaging
# Build production images
docker-compose -f docker-compose.prod.yml build
# Start services
docker-compose -f docker-compose.prod.yml up -dSee DEPLOYMENT.md for detailed instructions.
cd terraform
# Initialize Terraform
terraform init
# Review changes
terraform plan
# Apply infrastructure
terraform applyInfrastructure created:
- VPC with public/private subnets across 3 AZs
- RDS PostgreSQL 15 with Multi-AZ
- ElastiCache Redis cluster
- S3 bucket with encryption
- CloudFront CDN distribution
- ECS Fargate cluster with auto-scaling
- Application Load Balancer with HTTPS
- Route53 DNS records
- CloudWatch monitoring and alarms
Estimated monthly cost: $470-620
Core Tables:
User- User accounts (creators and subscribers)CreatorProfile- Creator-specific dataSubscriberProfile- Subscriber-specific dataContent- Content postsContentFile- Media files for contentMedia- Media metadata and processing status
Subscription System:
SubscriptionTier- Tier configurationsSubscription- Active subscriptionsTransaction- Payment transactionsPayout- Creator payouts
Messaging:
Conversation- Conversation metadataMessage- Chat messages
Supporting:
Notification- User notificationsWebhook- Stripe webhook logsRefreshToken- JWT refresh tokens
POST /register- User registrationPOST /login- User login (with optional 2FA)POST /refresh- Refresh access tokenPOST /logout- Logout and invalidate tokensGET /me- Get current userPOST /2fa/enable- Enable 2FA and get QR codePOST /2fa/verify- Verify 2FA codePOST /2fa/disable- Disable 2FA
GET /me- Get user profileGET /:username- Get user by usernamePUT /profile- Update profileGET /stats- Get user statistics
GET /feed- Get public content feedGET /feed/subscriptions- Get subscriptions feedGET /my-content- Get own contentPOST /- Create new contentGET /:id- Get content by IDPUT /:id- Update contentDELETE /:id- Delete contentPOST /:id/like- Like/unlike contentPOST /:id/unlock- Unlock PPV content
POST /upload- Upload media fileGET /signed-url/:id- Get signed URL for mediaDELETE /:id- Delete media
POST /connect/create- Create Stripe Connect accountGET /connect/onboarding-link- Get onboarding linkGET /connect/status- Get onboarding statusGET /earnings- Get earnings summaryGET /creator/earnings- Get detailed creator earningsGET /transactions- Get transaction historyPOST /payout/request- Request payoutGET /payouts- Get payout history
GET /my-subscriptions- Get my subscriptionsGET /my-subscribers- Get my subscribersGET /creator/:id/tiers- Get creator tiersPOST /subscribe- Subscribe to creator
GET /conversations- Get conversationsGET /:partnerId- Get messages with partnerDELETE /:messageId- Delete message
WebSocket (/messaging)
message:send- Send messagemessage:typing- Typing indicatormessage:read- Mark as readmessage:new- Receive new messagemessage:sent- Message sent confirmationuser:online/user:offline- Online status
- JWT access tokens (15 min expiry)
- Refresh tokens with rotation
- TOTP-based 2FA
- bcrypt password hashing (12 rounds)
- Role-based access control (RBAC)
- AES-256 encryption at rest (S3)
- TLS 1.3 in transit
- Signed URLs with expiration (1 hour)
- Rate limiting (Redis)
- Input validation (class-validator)
- SQL injection protection (Prisma)
- Content Security Policy (CSP)
- HTTP Strict Transport Security (HSTS)
- X-Frame-Options: DENY
- X-Content-Type-Options: nosniff
- Signed URLs for private content
- Automatic watermarking
- EXIF data stripping
- Malware scanning (planned)
- Redis for API responses
- CloudFront CDN for media
- React Query client-side cache
- Database connection pooling
- Image optimization with Sharp
- Video transcoding with FFmpeg
- Lazy loading and code splitting
- Database indexes on frequently queried fields
- Bull queues for async processing
- CloudWatch for infrastructure metrics
- Sentry for error tracking
- Custom performance dashboards
- Health check endpoints
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Commit Convention: Use conventional commits (feat, fix, docs, style, refactor, test, chore)
Phase 1 (Completed):
- ✅ Backend API with NestJS
- ✅ Authentication with 2FA
- ✅ Media upload and processing
- ✅ Stripe Connect integration
- ✅ Frontend with Next.js
- ✅ Real-time messaging
- ✅ Analytics dashboard
- ✅ E2E testing
- ✅ Production deployment setup
Phase 2 (Planned):
- Mobile apps (React Native)
- Live streaming (WebRTC)
- Advanced content moderation (AI)
- Multi-language support (i18n)
- NFT integration
- Advanced analytics (ML predictions)
- Creator collaboration features
- Referral/affiliate program
MIT License - see LICENSE file for details
- Documentation: docs/
- Issues: GitHub Issues
- Email: support@ofm-platform.com
- Built with NestJS and Next.js
- UI components from Shadcn/ui
- Icons from Lucide
- Charts from Recharts
- Testing with Playwright
- Infrastructure with Terraform
Made with ❤️ for content creators worldwide