A rigorous proof-of-concept for complex distributed systems architectures. Features custom-engineered infrastructure components including a proprietary Load Balancer, a configurable Dual-Mode Message Queue system, and bespoke Rate Limiting algorithms, protecting a geospatial social network.
📄 Engineering Specification (PDF) » · 🏛 System Architecture » · ⚙️ Proprietary Components »
- Project Overview
- Core Application Capabilities
- Key Architectural Highlights
- System Architecture
- Technology Stack
- Installation and Setup
- Configuration and Infrastructure Switching
- Performance and Concurrency
- Monitoring and Observability
The system relies on a bespoke "Edge Layer" to handle traffic before it reaches the core business logic.
graph TD;
Client[Angular Client] -->|HTTP/REST| RateLimiter[Custom Rate Limiter];
subgraph "Proprietary Infrastructure Layer"
RateLimiter --> LoadBalancer[Custom Load Balancer];
LoadBalancer -->|Strategy: Round Robin| Instance1[Spring Boot Node 1];
LoadBalancer -->|Strategy: Least Conn| Instance2[Spring Boot Node 2];
end
subgraph "Messaging Infrastructure (Dual-Mode)"
Instance1 -->|Interface: IMessageQueue| MQ_Switch{Profile Switch};
MQ_Switch -->|Profile: 'custom'| CustomMQ[Proprietary In-Memory Queue];
MQ_Switch -->|Profile: 'rabbitmq'| RabbitMQ[RabbitMQ Broker];
CustomMQ -->|Fanout| AdService[External Ad Service];
CustomMQ -->|Direct| VetService[Vet Location Service];
end
Instance1 --> Database[(PostgreSQL)];
Instance2 --> Database;
This is a sophisticated social networking solution designed to address specific market gaps in the pet ownership community. While outwardly presented as a niche platform for rabbit enthusiasts, the underlying system acts as a rigorous proof-of-concept for complex distributed systems architectures.
The platform provides a comprehensive ecosystem where users can curate digital identities, publish geo-tagged content, engage in real-time communication, and interact with external service providers (veterinarians, shelters). It solves the problem of fragmented information in the lagomorph care sector by unifying social interaction, care resource discovery, and multimedia sharing into a single, cohesive, and resilient application.
The application logic is partitioned into distinct functional domains, ensuring a seamless user experience ranging from unauthenticated discovery to administrative oversight.
- Public Access: Unauthenticated users possess restricted "Read-Only" access to the global content feed (sorted chronologically) and user profiles, but are strictly blocked from interactive features (Liking, Commenting) via server-side guards.
- Secure Registration: The onboarding process employs Bloom Filters for O(1) username uniqueness checks and transactional locking to prevent race conditions during simultaneous registrations. Accounts utilize email-based activation flows.
- Profile Management: Users maintain detailed profiles including follower/following metrics, personal post history, and immutable statistics.
- Geo-Spatial Publishing: Posts consist of rich media (images), textual descriptions, and precise geolocation data. Users can pinpoint locations via an interactive map interface.
- Engagement Engine: The system supports complex social interactions including likes, temporal-rate-limited commenting (max 60/hour), and following mechanisms (max 50/minute) designed to prevent bot spam.
- Trending Algorithms: A sophisticated analytics engine calculates "Trending" status based on interaction velocity over 7-day, 30-day, and all-time windows, caching results for performance.
- Synchronous Chat: Built on WebSockets, the chat module supports private messaging and dynamic group environments with admin privileges and history retention.
- Veterinary Service Discovery: Through a Direct Exchange message queue pattern, the application integrates with external "Rabbit Care" organizations to ingest and display real-time locations of vet clinics and shelters on the user's map.
- AdTech Fanout: A Fanout Exchange pattern broadcasts high-engagement posts to external advertising agencies, demonstrating multi-consumer message distribution.
- Business Intelligence Dashboard: Administrators utilize radial graphs and linear charts to visualize system health, including user retention rates, posting frequency, and engagement ratios.
- User Management: Advanced filtering, sorting, and pagination tools allow admins to audit the user base.
- Automated Housekeeping:
- Media Compression: Daily scheduled tasks iterate through new image assets to apply compression algorithms, optimizing storage.
- Account Pruning: Automated purging of unactivated accounts occurs on the last day of every month.
- Re-engagement: Automated notification emails are dispatched to users inactive for 7+ days.
This system distinguishes itself through three major custom-engineered components, demonstrating deep understanding of distributed system internals.
The application implements an interface-driven design for asynchronous messaging, allowing administrators to toggle between an industry-standard solution and a proprietary implementation using Spring Profiles.
- Profile A (
rabbitmq): Leverages the full AMQP protocol for production-grade reliability using RabbitMQ. - Profile B (
custom): A bespoke, thread-safe queuing system built from the ground up. It supports:- Direct Exchange Pattern: Point-to-point communication used for ingesting veterinary location data.
- Fanout Exchange Pattern: Broadcasting mechanism used for distributing promoted posts to external advertising agencies.
- Persistence: Custom serialization to ensure message durability.
To ensure high availability and horizontal scalability, a custom Load Balancing Service sits at the edge of the network.
- Algorithms: Implements configurable distribution strategies (e.g., Round Robin, Least Connections).
- Health Checking: Active probing of application instances to remove unhealthy nodes from rotation.
- Retry Policy: Automated request rerouting in the event of instance failure, ensuring zero downtime for end-users.
A dedicated defensive programming module designed to protect the API from abuse and bot activity.
- Mechanism: Uses a sliding window algorithm stored in volatile memory.
- Granularity: Enforces a strict limit of 5 requests per minute per IP address on sensitive endpoints (e.g., Authentication, Commenting).
- Efficiency: Optimized for O(1) complexity to introduce negligible latency to valid requests.
The system follows a layered architecture designed for separation of concerns and maintainability.
- Client Layer: An Angular Single Page Application (SPA) offering a responsive, component-based interface.
- Edge Layer:
- Custom Rate Limiter: Protects entry points.
- Custom Load Balancer: Distributes traffic across backend instances.
- Application Layer: Java Spring Boot RESTful API services handling core logic, transaction management, and WebSocket connections.
- Messaging Layer: Polymorphic bean injection allowing for runtime switching between RabbitMQ and Custom MQ.
- Data Persistence Layer: PostgreSQL for relational data and file systems for media storage.
- Observability Layer: Prometheus and Grafana for metrics and visualization.
The technology choices reflect a commitment to stability, strong typing, and enterprise adoption.
- Java 17+ / Spring Boot: Chosen for dependency injection, transaction management (
@Transactional), and robust security context. - Spring Data JPA / Hibernate: For Object-Relational Mapping (ORM).
- Spring Security: For implementing rigorous authentication and authorization chains.
- WebSockets (STOMP): For low-latency, real-time messaging.
- Angular (v16+): Selected for its rigorous structure, TypeScript integration, and dependency injection patterns which mirror the backend architecture.
- RxJS: Used for reactive state management and handling asynchronous data streams.
- Leaflet / OpenLayers: For rendering complex geospatial data.
- PostgreSQL: The primary relational database system.
- Prometheus & Grafana: Used for white-box monitoring of system metrics (CPU usage, Request latency, Active users).
- Docker: Containerization of services.
- Java Development Kit (JDK) 17 or higher
- Node.js (v18+) and npm
- PostgreSQL 14+
- RabbitMQ (Optional, if not using Custom MQ)
-
Clone the Repository
git clone https://github.com/bteodora/rabbit-social-media-platform.git cd rabbit-social-platform -
Database Configuration Ensure PostgreSQL is running and create the
onlybuns_dbdatabase. -
Backend Initialization
cd backend ./mvnw clean install ./mvnw spring-boot:run -
Frontend Initialization
cd frontend/RabbitApp npm install ng serve -
Access Points
- Frontend:
http://localhost:4200 - Backend API:
http://localhost:8080 - Load Balancer Entry:
http://localhost:8090(if enabled)
- Frontend:
The system architecture utilizes Spring Profiles to dynamically load infrastructure components at runtime. This allows for seamless transitions between the custom-built educational infrastructure and production-grade message brokers without code alteration.
To switch the underlying messaging architecture, modify the src/main/resources/application.properties file:
# -----------------------------------------------------------
# MESSAGE QUEUE STRATEGY SELECTION
# -----------------------------------------------------------
# 'rabbitmq' - Uses the external RabbitMQ broker (AMQP)
# 'custom' - Uses the internal proprietary Message Queue implementation
# -----------------------------------------------------------
spring.profiles.active=rabbitmqWhen utilizing the custom profile, the system initializes internal socket listeners on dedicated ports:
# Custom MQ Settings (Active only when profile is 'custom')
app.custom.mq.port=9090
app.custom.mq.persistence=trueThe system addresses the Lost Update and Phantom Read phenomena through:
- Pessimistic Locking: Applied to critical database rows (e.g., during "Like" incrementation or Follow actions).
- Thread Simulation:
Thread.sleep()is utilized in test profiles to deterministically simulate race conditions and verify lock integrity.
A Level 2 (L2) cache is implemented for frequently accessed data:
- Geospatial Data: Post locations are cached to reduce read latency on map rendering.
- Trend Calculation: Computationally expensive trend analysis is cached and refreshed periodically.
The system includes a dedicated telemetry module. Using Prometheus exporters, the application exposes:
- HTTP Metrics: Average request duration over a 24-hour window.
- System Metrics: Real-time CPU and Memory utilization.
- Business Metrics: Number of concurrent active users.
These metrics are visualized in Grafana dashboards, allowing operations teams to proactively identify bottlenecks.