A microservices-based social platform with a Next.js web client, a NestJS core API, a Socket.IO realtime server, a FastAPI analytics and recommendation service, and a Flask admin panel.
The system is split into specialized services communicating over REST, WebSockets, and Redis pub/sub.
graph TD
Client[Client App / Web] --> Ingress[Nginx Ingress / Gateway]
Ingress --> Web[Web App - Next.js 15]
Ingress --> Core[Core Service - NestJS]
Ingress --> Realtime[Realtime Service - Express / Socket.io]
Ingress --> Analytics[Analytics Service - FastAPI]
Ingress --> Admin[Admin Service - Flask]
Core --> DB_PG[(PostgreSQL Core)]
Core --> Redis[(Redis Cache / Broker)]
Core --> S3[Object Storage / Cloudinary]
Realtime --> Redis
Realtime --> DB_PG
Analytics --> DB_PG_Analytic[(PostgreSQL Analytics)]
Admin --> DB_PG
Admin --> DB_PG_Analytic
| Component | Technology | Description |
|---|---|---|
| Frontend | Next.js 15, React 19, Tailwind CSS 4 | App Router, SSR, responsive UI, dark/light themes |
| Auth | Clerk | Authentication, session management, webhooks |
| Core API | NestJS (TypeScript) | User accounts, feed generation, posts, follows, comments, search |
| Realtime | Express + Socket.IO | Direct messaging, live notification delivery, online presence |
| Analytics | FastAPI (Python) | Metric collection, hashtag trends, recommendation scoring |
| Admin | Flask (Python) | Moderation queues, audit logs, GDPR compliance |
| Database | PostgreSQL 16 + Prisma | Relational data models, migrations, seeds |
| Cache & Broker | Redis 7 | Caching, session states, pub/sub communication |
| Media Storage | Cloudinary / S3 | Image and video uploads, asset optimization |
| Gateway | Nginx | Reverse proxy, path routing, rate limiting |
| Observability | Prometheus + Grafana + Loki | Metrics dashboards, log aggregation |
| IaC | Terraform, Kubernetes, Helm | AWS topology and Kubernetes cluster resources |
| CI/CD | GitHub Actions | Workflows for build checks, linting, and tests |
- Node.js 20+ and pnpm 9+
- Python 3.12+
- Docker and Docker Compose
-
Clone the repository:
git clone https://github.com/eng-muhammad-hamza/next-flux.git cd next-flux -
Create the environment configuration:
cp .env.example .env
Fill in your Clerk credentials, database passwords, and third-party API keys in
.env. -
Launch the container stack:
docker compose up -d
-
Service endpoints:
- Web application:
http://localhost:3000 - Core API:
http://localhost:4000 - Realtime service:
http://localhost:4001 - Analytics service:
http://localhost:4002 - Admin service:
http://localhost:4003
- Web application:
next-flux/
├── apps/
│ └── web/ # Next.js 15 web client
├── services/
│ ├── core/ # NestJS service (users, posts, feed, notifications)
│ ├── realtime/ # Express & Socket.IO service (messaging, presence)
│ ├── analytics/ # FastAPI service (recommendation scoring, trends)
│ └── admin/ # Flask service (moderation, audit logs, GDPR)
├── packages/
│ ├── database/ # Prisma schema, migrations, seed scripts
│ └── shared/ # Common TypeScript interfaces and DTOs
├── gateway/ # Nginx reverse proxy configuration
├── infrastructure/
│ ├── terraform/aws/ # AWS infrastructure (VPC, ECS, RDS, Redis, S3)
│ ├── terraform/kubernetes/ # Terraform Kubernetes provider setup
│ ├── kubernetes/ # Deployments, services, HPA, network policies
│ ├── helm/flux/ # Helm charts for staging and production
│ └── monitoring/ # Prometheus configs, Grafana dashboards, Loki
├── .github/workflows/ # CI/CD automation pipelines
├── api-collections/ # API request examples and curl commands
├── docs/ # Architecture, API specifications, and runbooks
└── docker-compose.yml # Local multi-service orchestration
For active service development without full containerization:
# Core service (NestJS)
cd services/core
pnpm install
pnpm run start:dev
# Realtime service (Express / Socket.IO)
cd services/realtime
pnpm install
pnpm run dev
# Analytics service (FastAPI)
cd services/analytics
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
uvicorn app.main:app --reload --port 4002
# Admin service (Flask)
cd services/admin
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
flask run --port 4003 --debug
# Web application (Next.js)
cd apps/web
pnpm install
pnpm run devThe analytics microservice provides a multi-stage post recommendation pipeline:
- Candidate Selection & Graph Matching: Hashtag overlap via Jaccard similarity and follow-graph proximity.
- Engagement & Recency Decay: Time-decay scoring based on likes, comments, and reposts.
- Semantic Scoring: Optional LLM re-ranking through OpenRouter (
OPENROUTER_API_KEY). Falls back to algorithmic score weights when the key is omitted. - Caching: In-memory TTL layer for frequently queried feeds.
Run the engine tests:
pytest services/analytics/tests/test_recommendation_engine.py -vcd infrastructure/helm
helm install flux ./flux -n flux -f flux/values-dev.yamlcd infrastructure/terraform/aws
terraform init
terraform apply -var-file=environments/dev.tfvarsRefer to docs/deployment-runbook.md for production deployment procedures and rollback steps.
- Grafana:
http://localhost:3001(default credentials:admin/admin) - Prometheus:
http://localhost:9090 - Loki:
http://localhost:3100
- Architecture Guide
- API Reference
- Development Guide
- Deployment Runbook
- Security Model
- API Collections
This project is licensed under the MIT License.