Skip to content

Hamza-El-Azzouzi/Orbit

Repository files navigation

Orbit

Orbit Logo

Orbit

A modern microservices-based social blogging platform

Overview

Orbit is a comprehensive social blogging platform built with a microservices architecture. The platform enables users to create and share content, follow others, interact through likes and comments, and report inappropriate content. Administrators have dedicated tools to manage users, content moderation, and platform analytics.

Key Features

  • User Management: Registration, authentication (JWT/Spring Security), profile customization
  • Content Creation: Posts with media support (images/videos via AWS S3)
  • Social Interactions: Follow users, like and comment on posts
  • Content Discovery: Search functionality powered by Elasticsearch
  • Moderation System: Report inappropriate content for admin review
  • Admin Dashboard: Comprehensive tools for platform management
  • Analytics: User engagement and content performance tracking

Architecture

Orbit is built with a microservices architecture, consisting of:

  • API Gateway: Entry point for all client requests
  • User Service: Handles user authentication and profile management
  • Blog Service: Manages blog posts, comments, and media uploads
  • Notification Service: Processes and delivers real-time notifications
  • Admin Service: Provides administrator functionality
  • Report Service: Manages content moderation and reporting
flowchart TD
    Client[Client Application] <--> Gateway[API Gateway]
    Gateway <--> UserService[User Service]
    Gateway <--> BlogService[Blog Service]
    Gateway <--> NotificationService[Notification Service]
    Gateway <--> AdminService[Admin Service]
    Gateway <--> ReportService[Report Service]
    
    
    UserService <--> UserDB[(User DB)]
    UserService <--> ES[Elasticsearch]
    BlogService <--> BlogDB[(Blog DB)]
    NotificationService <--> NotificationDB[(Notification DB)]
    AdminService <--> AdminDB[(Admin DB)]
    ReportService <--> ReportDB[(Report DB)]

   
    BlogService <--> S3[AWS S3]
    BlogService <--> ES[Elasticsearch]
    
    
    Kafka[Apache Kafka] <--> UserService
    Kafka <--> BlogService
    Kafka <--> NotificationService
    Kafka <--> AdminService
    Kafka <--> ReportService
    
    subgraph Data Stores
        ES
        UserDB
        BlogDB
        NotificationDB
        AdminDB
        ReportDB
        S3
        
    end
    
    subgraph Messaging
        Kafka
    end
Loading

Tech Stack

Backend

  • Framework: Java 17, Spring Boot 3.5
  • API: Spring Web, Spring Cloud Gateway
  • Security: Spring Security, JWT
  • Database: PostgreSQL (multiple dedicated databases per service)
  • Search: Elasticsearch 8.15
  • Messaging: Apache Kafka for inter-service communication
  • Storage: AWS S3 for media files
  • Build Tool: Maven

Frontend

  • Framework: Angular 20
  • UI Components: Angular Material
  • State Management: NgRx
  • Styling: CSS with responsive design
  • Build Tool: npm

DevOps

  • Containerization: Docker, Docker Compose

Running the Application

Prerequisites

  • Java 17 or higher
  • Node.js 18+ and npm
  • Docker and Docker Compose
  • AWS Account (for S3 media storage)

Environment Setup

  1. Create a .env file in the project root with the following variables:
POSTGRES_USER=your_postgres_user
POSTGRES_PASSWORD=your_postgres_password
ELASTIC_PASSWORD=your_elastic_password
AWS_ACCESS_KEY_ID=your_aws_access_key
AWS_SECRET_ACCESS_KEY=your_aws_secret_key

Option 1: Running with Docker (Recommended)

The easiest way to run the entire application is using Docker Compose:

# Start all services
docker compose up

# Start specific service
docker compose up blog-service

# Build and start services
docker compose up --build

# Run in detached mode
docker compose up -d

This will start:

  • PostgreSQL with multiple databases
  • Elasticsearch for search functionality
  • Apache Kafka and ZooKeeper for messaging
  • All microservices (user, blog, notification, admin, report, api-gateway)
  • Frontend Angular application

Option 2: Running Services Individually

Backend Services

To run each service individually (useful for development):

# For each service (user-service, blog-service, etc.)
cd [service-name]
./mvnw spring-boot:run

Service ports:

  • API Gateway: 8080
  • User Service: 8081
  • Blog Service: 8082
  • Notification Service: 8083
  • Report Service: 8084
  • Admin Service: 8085

Frontend

To run the Angular frontend:

cd frontend
npm install
npm start

The frontend will be available at http://localhost:4200

Project Structure

orbit/
├── api-gateway/               # API Gateway service (Spring Cloud Gateway)
├── user-service/              # User management, authentication, profiles
├── blog-service/              # Blog posts, comments, media uploads
├── notification-service/      # Real-time notifications
├── report-service/            # Content reporting and moderation
├── admin-service/             # Administrator dashboard and tools
├── frontend/                  # Angular frontend application
│   ├── src/
│   │   ├── app/              # Angular components, services, modules
│   │   ├── assets/           # Static assets (images, icons, etc.)
│   │   └── global_styles.css # Global styles
│   ├── angular.json          # Angular configuration
│   └── package.json          # Frontend dependencies
├── docker-compose.yml        # Docker Compose configuration for all services
├── run.sh                    # Script to set up Docker environment and run app
└── multiple-databases.sh     # Script to initialize multiple PostgreSQL databases

Additional Features

Media Storage with AWS S3

The platform uses AWS S3 for storing and serving media files (images and videos) with the following features:

  • Automatic file organization in dedicated folders
  • Content-type detection and metadata preservation
  • UUID-based filenames to prevent collisions
  • Public read access for direct file serving

Elasticsearch Integration

Full-text search capabilities for:

  • Blog posts by title
  • User profiles

Component Diagram

---
config:
  layout: elk
  theme: redux-dark
---
flowchart TB
 subgraph client["Client Layer"]
        Browser["Web Browser"]
  end
 subgraph frontend["Frontend Application (Angular)"]
        UI["UI Components"]
        AuthInterceptor["Auth Interceptor"]
        ErrorHandler["Error Handler"]
        StateManagement["NgRx Store"]
        APIClient["HTTP Client"]
  end
 subgraph gateway["API Gateway"]
        Router["Route Configuration"]
        JwtFilter["JWT Authentication Filter"]
  end
 subgraph user["User Service"]
        UserController["REST API"]
        UserService["Service Layer"]
        UserRepository["Repository Layer"]
        UserEvents["Event Publisher"]
        SearchServiceUser["Elasticsearch"]
        EventConsumerUser["Event Consumer"]
  end
 subgraph blog["Blog Service"]
        BlogController["REST API"]
        BlogService["Service Layer"]
        BlogRepository["Repository Layer"]
        MediaService["S3 Integration"]
        SearchServiceBlog["Elasticsearch"]
        BlogEvents["Event Publisher"]
        EventConsumerBlog["Event Consumer"]
  end
 subgraph notification["Notification Service"]
        NotificationController["REST API"]
        NotificationService["Service Layer"]
        NotificationRepository["Repository Layer"]
        EventConsumerNotif["Event Consumer"]
  end
 subgraph admin["Admin Service"]
        AdminController["REST API"]
        AdminService["Service Layer"]
        AdminRepository["Repository Layer"]
        AdminEvents["Event Publisher"]
        EventConsumerAdmin["Event Consumer"]
  end
 subgraph report["Report Service"]
        ReportController["REST API"]
        ReportService["Service Layer"]
        ReportRepository["Repository Layer"]
        ReportEvents["Event Publisher"]
        EventConsumerReport["Event Consumer"]
  end
 subgraph services["Microservices"]
        user
        blog
        notification
        admin
        report
  end
 subgraph data["Data Layer"]
        PostgreSQL["PostgreSQL Databases"]
        Elasticsearch["Elasticsearch"]
        S3["AWS S3"]
  end
 subgraph messaging["Messaging"]
        Kafka["Apache Kafka"]
        Zookeeper["ZooKeeper"]
  end
    Browser --> frontend
    frontend --> gateway
    gateway --> user & blog & notification & admin & report
    user --> PostgreSQL
    blog --> PostgreSQL & Elasticsearch & S3
    notification --> PostgreSQL
    admin --> PostgreSQL
    report --> PostgreSQL
    UserEvents --> Kafka
    BlogEvents --> Kafka
    ReportEvents --> Kafka
    AdminEvents --> Kafka
    Kafka --> EventConsumerUser & Zookeeper & EventConsumerNotif & EventConsumerBlog & EventConsumerAdmin & EventConsumerReport
    UserController --> UserService
    UserService --> UserRepository & UserEvents & SearchServiceUser & EventConsumerUser
    BlogController --> BlogService
    BlogService --> BlogRepository & MediaService & SearchServiceBlog & BlogEvents & EventConsumerBlog
    NotificationController --> NotificationService
    NotificationService --> NotificationRepository & EventConsumerNotif
    AdminController --> AdminService
    AdminService --> AdminRepository & AnalyticsService["AnalyticsService"] & AdminEvents & EventConsumerAdmin
    ReportController --> ReportService
    ReportService --> ReportRepository & ReportEvents & EventConsumerReport
    UI --> AuthInterceptor & ErrorHandler & StateManagement
    StateManagement --> APIClient
    APIClient --> AuthInterceptor
    style services stroke:#BBDEFB
    L_Kafka_EventConsumerNotif_0@{ animation: none }

Loading

Development Notes

  • Configure service-specific settings in [service-name]/src/main/resources/application.properties
  • Each microservice has its own dedicated PostgreSQL database
  • Inter-service communication happens primarily through Kafka events
  • Frontend uses interceptors for authentication and error handling
  • Elasticsearch is used for full-text search functionality in the Blog Service
  • AWS S3 integration is used for media storage in the Blog Service
  • All services use Spring Boot 3.5 with Java 17
  • Docker and Docker Compose are used for containerization and orchestration

Use Cases

---
config:
  theme: redux-dark
  layout: elk
---
flowchart TB
 subgraph User_Service["User Service"]
    direction TB
        UC1["Register Account"]
        UC2["Login with JWT"]
        UC3["Logout"]
        UC5["View Profile"]
        UC7@{ label: "View User's Block" }
        UC8["Subscribe to User"]
        UC9["Unsubscribe from User"]
        UC10["Search Users"]
  end
 subgraph Blog_Service["Blog Service"]
    direction TB
        UC11["Create Post"]
        UC12["Edit Post"]
        UC13["Delete Post"]
        UC14["Upload Media to S3"]
        UC15["View Post Details"]
        UC16["View Feed"]
        UC17["Like Post"]
        UC18["Unlike Post"]
        UC19["Comment on Post"]
        UC20["Delete Comment"]
        UC21["Search Posts"]
  end
 subgraph Notification_Service["Notification Service"]
    direction TB
        UC22["View Notifications"]
        UC23["Mark as Read"]
        UC24["Process Events"]
        UC25["Send Notifications"]
  end
 subgraph Report_Service["Report Service"]
    direction TB
        UC26["Report User"]
        UC27["Report Post"]
        UC28["Report Comment"]
        UC29["Submit Report Details"]
  end
 subgraph Admin_Service["Admin Service"]
    direction TB
        UC30["View User List"]
        UC31["Manage User Status"]
        UC32["Delete User"]
        UC33["View Content"]
        UC34["Moderate Content"]
        UC35["Process Reports"]
        UC36["View Analytics"]
        UC37["Generate Reports"]
  end
    User(("User")) --> User_Service & Blog_Service & Notification_Service & Report_Service
    Admin(("Admin")) --> User_Service & Blog_Service & Notification_Service & Report_Service & Admin_Service
    System(("System")) --> User_Service & Blog_Service & Notification_Service & Report_Service & Admin_Service
    UC11 -. includes .-> UC14
    UC12 -. includes .-> UC14
    UC11 -. triggers .-> UC24
    UC17 -. triggers .-> UC24
    UC19 -. triggers .-> UC24
    UC8 -. triggers .-> UC24
    UC24 -. creates .-> UC25
    UC26 -. includes .-> UC29
    UC27 -. includes .-> UC29
    UC28 -. includes .-> UC29
    UC35 -. processes .-> UC26 & UC27 & UC28
    UC16 -. extends .-> UC17 & UC18
    UC15 -. extends .-> UC19
    UC22 -. extends .-> UC23
    Blog_Service -. publishes events .-> Notification_Service & Admin_Service
    User_Service -. publishes events .-> Notification_Service
    Report_Service -. publishes events .-> Admin_Service
    UC7@{ shape: rect}

Loading

Sequence Diagram

---
config:
  theme: redux-dark-color
---
sequenceDiagram
  actor User as User
  participant Frontend as Angular Frontend
  participant Gateway as API Gateway
  participant UserSvc as User Service
  participant BlogSvc as Blog Service
  participant NotifSvc as Notification Service
  participant ReportSvc as Report Service
  participant AdminSvc as Admin Service
  participant Kafka as Apache Kafka
  participant S3 as AWS S3
  participant ElasticSearch as Elasticsearch
  participant DB as PostgreSQL DBs
  autonumber
  Note over User, DB: User Registration & Authentication Flow
  User ->> Frontend: Register (username, email, password)
  Frontend ->> Gateway: POST /auth/register
  Gateway ->> UserSvc: Forward request
  UserSvc ->> DB: Save user data
  DB -->> UserSvc: User created
  UserSvc ->> Kafka: Publish UserCreatedEvent
  UserSvc -->> Gateway: Registration successful
  Gateway -->> Frontend: 201 Created + user data
  Frontend -->> User: Show success message
  User ->> Frontend: Login (email, password)
  Frontend ->> Gateway: POST /auth/login
  Gateway ->> UserSvc: Forward request
  UserSvc ->> DB: Validate credentials
  DB -->> UserSvc: User validated
  UserSvc -->> Gateway: JWT token + user data
  Gateway -->> Frontend: 200 OK + JWT
  Frontend -->> User: Redirect to dashboard
  Note over User, DB: Create Blog Post with Media
  User ->> Frontend: Create new post (title, content, media)
  Frontend ->> Gateway: POST /blog/posts (with JWT)
  Gateway ->> BlogSvc: Forward authenticated request
  BlogSvc ->> S3: Upload media file
  S3 -->> BlogSvc: Media URL
  BlogSvc ->> DB: Save post data
  DB -->> BlogSvc: Post created
  BlogSvc ->> ElasticSearch: Index post content
  BlogSvc ->> Kafka: Publish PostCreatedEvent
  BlogSvc -->> Gateway: Post created successfully
  Gateway -->> Frontend: 201 Created + post data
  Note over User, NotifSvc: Notification Processing
  Kafka ->> NotifSvc: Consume PostCreatedEvent
  NotifSvc ->> DB: Get subscriber list
  DB -->> NotifSvc: Subscriber IDs
  NotifSvc ->> DB: Create notifications
  
  Note over User, DB: Search Posts
  User ->> Frontend: Search for posts
  Frontend ->> Gateway: GET /blog/search?q=keyword
  Gateway ->> BlogSvc: Forward request
  BlogSvc ->> ElasticSearch: Search query
  ElasticSearch -->> BlogSvc: Search results Ids
  BlogSvc -->> DB: Get result with ides
  DB -->> BlogSvc: Results Posts
  BlogSvc -->> Gateway: Post search results
  Gateway -->> Frontend: 200 OK + search results
  Frontend -->> User: Display search results
  Note over User, DB: Report Inappropriate Content Or User
  User ->> Frontend: Report post (reason)
  Frontend ->> Gateway: POST /report
  Gateway ->> ReportSvc: Forward request
  ReportSvc ->> DB: Save report
  DB -->> ReportSvc: Report stored
  ReportSvc ->> Kafka: Publish ReportCreatedEvent
  ReportSvc -->> Gateway: Report submitted
  Gateway -->> Frontend: 201 Created
  Frontend -->> User: Show confirmation
  Note over User, AdminSvc: Admin Moderation
  Kafka ->> AdminSvc: Consume ReportCreatedEvent
  AdminSvc ->> DB: Update report queue
  User ->> Frontend: Access admin dashboard
  Frontend ->> Gateway: GET /admin/reports
  Gateway ->> AdminSvc: Forward request (with admin role)
  AdminSvc ->> DB: Get pending reports
  DB -->> AdminSvc: Reports data
  AdminSvc -->> Gateway: Reports list
  Gateway -->> Frontend: 200 OK + reports
  Frontend -->> User: Display admin dashboard
  User ->> Frontend: Resolve report (action)
  Frontend ->> Gateway: PUT /admin/reports/{id}/resolve
  Gateway ->> AdminSvc: Forward request
  AdminSvc ->> DB: Update report status
  AdminSvc ->> Kafka: Publish ReportResolvedEvent
  AdminSvc -->> Gateway: Resolution confirmed
  Gateway -->> Frontend: 200 OK
  Frontend -->> User: Update UI
  Note over User, DB: Notification Delivery
  User ->> Frontend: Open notifications
  Frontend ->> Gateway: GET /notifications
  Gateway ->> NotifSvc: Forward request
  NotifSvc ->> DB: Get user notifications
  DB -->> NotifSvc: Notification data
  NotifSvc -->> Gateway: Notifications list
  Gateway -->> Frontend: 200 OK + notifications
  Frontend -->> User: Display notifications

Loading

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Orbit is a comprehensive social blogging platform built with a microservices architecture. The platform enables users to create and share content, follow others, interact through likes and comments, and report inappropriate content. Administrators have dedicated tools to manage users, content moderation, and platform analytics.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors