Skip to content

Repository files navigation

๐Ÿš€ TypeScript Fullstack Pet Project

Modern real-time social platform with intelligent feeds, role system and advanced architecture

TypeScript NestJS React PostgreSQL RabbitMQ WebSocket Elasticsearch


๐ŸŽฏ About the project

Pet project exploring modern JS fullstack technologies

  • Posts and comments with unlimited nesting
  • Subscription system - follow users and get personalized feeds
  • Global search across posts, comments and users
  • Three-tier role system with admin panel and visual badges
  • Real-time updates for all content
  • Smart feeds - All/Following/User with intelligent caching
  • Optimistic UI - instant likes and reactions
  • Security - JWT auth + CAPTCHA protection + session management
  • Queue monitoring - performance control and automatic alerts
  • Stress testing - handles extreme loads with queue + batching architecture

๐Ÿ—๏ธ Architecture

Backend: Gateway โ†’ Queue โ†’ Consumer

NestJS backend with three-tier message processing: Gateway accepts requests and gives instant response โ†’ RabbitMQ queues ensure guaranteed delivery and horizontal scaling โ†’ Consumers process data and sync all clients via server.emit(). This provides UX without delays while maintaining data consistency.

Security includes multi-level WebSocket protection: rate limiting (20 req/min for users, 200 for admins), attack pattern detection (rapid fire, endpoint hammering), and JWT validation with role checking. WebSocket namespaces organize features (/users, /posts, /comments, /search) with room-based personalization for targeted updates.

Smart queue management uses TTL messages, lazy queues, message priorities, and real-time monitoring with automatic alerts when limits are exceeded. Built-in TestService generates massive test data with special privileges for stress testing.

Frontend: MobX + Virtual Scrolling

React 19 with MobX state management using strict mode and atomic transactions via runInAction. Observer components automatically re-render only affected parts, ensuring predictable updates. Singleton registry pattern with dependency injection provides clean architecture and eliminates circular dependencies.

Advanced batching system adapts processing strategies based on load (idle/low/medium/high/extreme) with dynamic batch sizes from 5 to 1000 elements. Virtual scrolling with TanStack handles thousands of posts efficiently using height estimation, DOM measurements, and intelligent caching.

Built-in testing panel allows mass data generation, stress testing UI, virtual scrolling tests, and admin tools. Optimistic UI provides instant feedback with background sync and auto-rollback on errors.


โšก Key Features

  • ๐ŸŽฏ Reactive Architecture - Atomic transactions ensure consistency with automatic rollback
  • ๐Ÿ”„ Smart Feed Management - Buffer new posts + manual mode + cross-tab persistence
  • ๐Ÿš€ Hybrid Processing - Instant user response + guaranteed background processing
  • โšก Optimistic UI - Instant updates with background sync and auto-rollback
  • ๐Ÿ“Š Proactive Monitoring - Real-time queue monitoring with automatic alerts
  • ๐Ÿ” Account Security - Single-device sessions with breach notifications
  • ๐Ÿงช Production Testing - Built-in load testing simulating thousands of users

๐ŸŽจ Reactive Rendering Flow

Virtual Scrolling Architecture
flowchart LR
    A[๐Ÿ“Š MobX Store] --> B[๐Ÿ”„ Observer]
    B --> C[๐Ÿ“ Height Cache]
    C --> D[๐Ÿ—๏ธ Virtualizer]
    D --> E[๐ŸŽจ Renderer]
    E --> F[๐Ÿ“ Measurements]
    F --> C
    
    subgraph "โšก Performance"
        G[Batching]
        H[Caching]
        I[Optimization]
    end
    
    D --> G
    C --> H
    E --> I
Loading

๐Ÿ› ๏ธ Tech Stack

Layer Technology Purpose
Frontend React 19 + TypeScript Type-safe reactive UI
State MobX 6 Observable state management
Backend NestJS + TypeScript Scalable server architecture
Database PostgreSQL + TypeORM Relational data with migrations
Queue RabbitMQ Reliable async processing
Real-time Socket.IO WebSocket communication
Search Elasticsearch Full-text search engine
Auth JWT + Guards Secure authentication

๐Ÿš€ Quick Start

Prerequisites

  • Docker & Docker Compose
  • Node.js 20+
  • Bash

๐ŸŽฏ Run Development

git clone https://github.com/lsthisloss/spa-comments.git
cd spa-comments
./run.sh
# Select option 1 for development mode

๐ŸŒ Access Points

๐ŸŽฎ First Steps

  1. Create superadmin account
  2. Generate test data via Settings โ†’ Admin Panel
  3. Run stress tests (superadmin only)

โš ๏ธ Note: Option 6 in run script deletes ALL Docker containers/images


๐ŸŽจ Demo

image


Timeline: 3 weeks
What I learned: Scalable architecture, real-time systems, performance optimization, security patterns
Coda: https://coda.io/@oleh-khad/jeez
Developed w/ โค๏ธ by sk8

About

A TypeScript-based fullstack SPA application with real-time updates, RabbitMQ queue, ability to use tags, add a txt file, image, captcha and nested replies

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages