Skip to content

abhiram-ar/humane-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

764 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Humane Backend

A behavior-rewarding, real-time social network built on microservices architecture

TypeScript Node.js Kubernetes Kafka

Overview

Humane Backend powers the server-side infrastructure of Humane, a human-first social platform focused on meaningful interactions, positive behavior, and real-world connection rather than attention-driven engagement. It is built as a scalable, event-driven microservices system. The platform uses Apache Kafka for asynchronous service communication, Kubernetes for orchestration, and a polyglot persistence strategy to balance consistency, performance, and scalability, while following Clean / Hexagonal Architecture principles for long-term maintainability.

System Architecture

System Architecture Open in interactive mode

Core Features

User Management

  • Authentication & Authorization: JWT-based auth with Google OAuth integration
  • User Profiles: Customizable profiles with avatar and cover photos
  • Friend System: Send/accept friend requests, manage relationships
  • Password Management: Secure password hashing, reset, and change functionality
  • Email Verification: Verification emails via nodemailer

Content Creation & Management

  • Posts: Create, update, delete posts with text and media attachments
  • Comments: Commenting system with like/unlike functionality
  • Likes: Like/unlike comments with real-time updates
  • Hashtags: Automatic hashtag extraction and indexing
  • Visibility Controls: Public and friends-only post visibility
  • Media Upload: Pre-signed URL generation for secure client-side uploads

Content Moderation

  • AI-Powered Moderation: Automated NSFW detection using pre-build CNN model
  • Video Processing: Frame extraction and analysis using FFmpeg
  • Multi-frame Analysis: Identifies "hottest" frames in video content
  • Configurable Thresholds: Admin-adjustable sensitivity for content flagging
  • User Notifications: Alerts for flagged or failed moderation

Real-time Chat

  • 1-1 Messaging: WebSocket-based instant messaging via Socket.IO
  • Online Status: Real-time user presence tracking
  • Read Receipts: Conversation-level read tracking (timestamp-based)
  • Message Persistence: Reliable message delivery with acknowledgments
  • Reward Integration: Gamified engagement for active conversations

Notifications

  • Real-time Delivery: WebSocket-based instant notifications
  • Event-driven: Kafka consumers trigger notifications for various events
  • Types Supported: Friend requests, comments, likes, moderation alerts
  • Pagination: Efficient infinite scroll for notification history

Search & Discovery

  • Full-text Search: Elasticsearch-powered search for posts, comments, users
  • User Timeline: Paginated user post history
  • Feed Optimization: Redis-cached personalized feeds

Gamification & Rewards

  • Humane Score: Point system for user engagement
  • Configurable Rewards: Admin-configurable point values for actions
  • Activity Tracking: Automated reward distribution via Kafka events
  • Leaderboards: Platform-wide reward statistics

Observability

  • Prometheus Metrics: Custom metrics for all services
  • Grafana Dashboards: Visualization and monitoring
  • Distributed Logging: Centralized logging with Grafana Alloy and Loki
  • Service Health: Readiness and liveness probes

Non-functional requirements: Scalability & Resilience

  • Batch Processing: Batching likes, comments, and reward count updates for efficiency
  • Kubernetes Orchestration: Automated deployment, scaling, and management
  • Event-driven Architecture: Loose coupling via Kafka for scalability
  • Polyglot Persistence: Optimized data storage strategies per service

🛠️ Development Setup

Prerequisites

  • Node.js 22+
  • Docker & Docker Compose
  • Kubernetes (Docker Desktop, k3s or Minikube)
  • Skaffold CLI
  • kubectl

Quick Start

1. Clone the repository

git clone https://github.com/abhiram-ar/humane-backend.git
cd humane-backend

2. Initialize submodules

git submodule update --init --recursive

3. Start infrastructure components

Manually start the infrastructure comonents like kafka, elasticsearch, databases, Api gateway etc. using the manifests or helper scripts in infra/k8s-dev-manual/.

4. Start the microservices

a. Start in development mode:
skaffold dev

This command will:

  • Build all microservices
  • Deploy to local Kubernetes cluster
  • Enable hot-reloading for development when code changes are detected
b. Start in production mode:
skaffold run --config skaffold.prod.yaml

This command will:

  • Pull pre-built Docker images from Docker Hub
  • Deploy to local Kubernetes cluster

5. Access services

  • Frontend: http://localhost:5173 (via humane-frontend submodule)
  • API Gateway: Available via Kubernetes ingress
  • Grafana: Port-forward to access dashboards

Environment Variables

Each service requires specific environment variables. Refer to individual service README files for details:

Contributing

We welcome contributions! Please follow these guidelines:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Follow code style and linting rules (Prettier config included)
  4. Write unit and integration tests
  5. Document API changes and data schema modifications
  6. Submit a pull request

Code Standards

  • Use TypeScript strict mode
  • Follow existing architectural patterns (Clean Architecture/Hexagonal)
  • Write meaningful commit messages
  • Keep services decoupled and event-driven

Documentation

Acknowledgments

  • NSFWJS for NSFW image classification model
  • The open-source community for amazing tools and libraries
  • Inspired by modern social that drifed from what social media should be.

Built with ❤️ for a more humane social experience

About

Event-driven microservices backend for Humane, a behavior-rewarding social platform. Implements CQRS with Kafka for eventual consistency, Elasticsearch for global search, and polyglot persistence, with ML-powered moderation pipelines for content safety.

Topics

Resources

License

Stars

Watchers

Forks

Contributors