Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A complete real-time notification system using PostgreSQL LISTEN/NOTIFY with a modern service-oriented architecture, multi-tenant support, and enhanced data generation.

Notifications You must be signed in to change notification settings

talaatmagdyx/notify_postgres

Repository files navigation

PostgreSQL Notification System

A complete real-time notification system using PostgreSQL LISTEN/NOTIFY with a modern service-oriented architecture, multi-tenant support, and enhanced data generation.

πŸ—οΈ Service Architecture

notify_postgres/
β”œβ”€β”€ πŸ“ services/                    # Service-oriented architecture
β”‚   β”œβ”€β”€ πŸ“ backend/                 # Multi-tenant Flask API Service
β”‚   β”‚   β”œβ”€β”€ unified_app.py          # Unified multi-tenant backend
β”‚   β”‚   β”œβ”€β”€ multi_tenant_app.py     # Multi-tenant backend
β”‚   β”‚   β”œβ”€β”€ app.py                  # Legacy single-tenant backend
β”‚   β”‚   β”œβ”€β”€ start_comp_*.sh         # Company-specific startup scripts
β”‚   β”‚   β”œβ”€β”€ requirements.txt        # Backend dependencies
β”‚   β”‚   β”œβ”€β”€ config.ini              # Service configuration
β”‚   β”‚   └── Dockerfile              # Container configuration
β”‚   β”œβ”€β”€ πŸ“ frontend/                # React Frontend Service
β”‚   β”‚   β”œβ”€β”€ src/                    # React source code
β”‚   β”‚   β”‚   β”œβ”€β”€ App.tsx             # Main multi-tenant app
β”‚   β”‚   β”‚   β”œβ”€β”€ App.css             # Modern glass-morphism styling
β”‚   β”‚   β”‚   └── App_Company*.tsx    # Company-specific components
β”‚   β”‚   β”œβ”€β”€ public/                 # Static files
β”‚   β”‚   β”œβ”€β”€ package.json            # Frontend dependencies
β”‚   β”‚   β”œβ”€β”€ config.ini              # Service configuration
β”‚   β”‚   └── Dockerfile              # Container configuration
β”‚   β”œβ”€β”€ πŸ“ notification-engine/      # Notification Engine Service
β”‚   β”‚   β”œβ”€β”€ unified_system.py       # Unified multi-tenant system
β”‚   β”‚   β”œβ”€β”€ multi_tenant_system.py  # Multi-tenant notification system
β”‚   β”‚   β”œβ”€β”€ notification_system.py  # Core notification system
β”‚   β”‚   β”œβ”€β”€ config.ini              # Service configuration
β”‚   β”‚   └── Dockerfile              # Container configuration
β”‚   β”œβ”€β”€ πŸ“ database/                # Database Service
β”‚   β”‚   β”œβ”€β”€ multi_tenant_schema.sql # Multi-tenant database schema
β”‚   β”‚   β”œβ”€β”€ multi_tenant_generator.py # Enhanced Faker-based data generator
β”‚   β”‚   β”œβ”€β”€ schema.sql              # Single-tenant database schema
β”‚   β”‚   └── config.ini              # Service configuration
β”‚   β”œβ”€β”€ multi_tenant_manager.sh     # Multi-tenant service management
β”‚   └── service-manager.sh          # Service management script
β”œβ”€β”€ πŸ“ scripts/                     # Utility Scripts
β”œβ”€β”€ πŸ“ tests/                       # Test Files
β”œβ”€β”€ πŸ“ docs/                        # Documentation
β”œβ”€β”€ πŸ“„ docker-compose.yml           # Docker orchestration
β”œβ”€β”€ πŸ“„ Makefile                     # Easy command shortcuts
β”œβ”€β”€ πŸ“„ MULTI_TENANT_README.md       # Multi-tenant documentation
└── πŸ“„ README.md                    # This file

πŸš€ Quick Start

Option 1: Multi-Tenant Setup (Recommended)

# Start multi-tenant services
make start-multi

# Generate realistic test data
make generate

# Access the unified frontend
open http://localhost:3000

Option 2: Docker Compose

# Start all services with Docker
docker-compose up -d

# View logs
docker-compose logs -f

# Stop all services
docker-compose down

Option 3: Service Manager

# Start all services
./services/service-manager.sh start all

# Start specific service
./services/service-manager.sh start backend

# Check status
./services/service-manager.sh status

# Stop all services
./services/service-manager.sh stop all

Option 4: Manual Start

# Setup database
make setup

# Start services individually
make backend
make frontend

🎯 Services

🏒 Multi-Tenant Backend Services

  • TechFlow Solutions: Port 5001 (Technology industry)
  • SocialMedia Pro: Port 5002 (Social Media Marketing)
  • OmniChannel Corp: Port 5003 (E-commerce)
  • Type: Flask API + WebSocket
  • Features: Multi-tenant REST API, real-time notifications, company-specific routing
  • Start: make start-multi or ./services/multi_tenant_manager.sh start

πŸ“± Unified Frontend Service

  • Port: 3000
  • Type: React Web App with Multi-Tenant Support
  • Features:
    • Modern glass-morphism UI design
    • Company switching with dynamic themes
    • Real-time notifications with beautiful animations
    • Analytics dashboard with comprehensive metrics
    • WhatsApp-like interface for engagements
  • Start: ./services/service-manager.sh start frontend

⚑ Unified Notification Engine

  • Type: Background Service
  • Features:
    • Multi-tenant PostgreSQL LISTEN/NOTIFY processing
    • Company-specific notification routing
    • Real-time WebSocket event distribution
    • Enhanced notification payloads
  • Start: ./services/service-manager.sh start engine

πŸ—„οΈ Multi-Tenant Database Service

  • Port: 5432
  • Type: PostgreSQL Database with Multi-Tenant Schemas
  • Features:
    • Separate schemas for each company
    • Enhanced triggers and notification functions
    • Realistic test data generation with Faker
    • Comprehensive analytics tables
  • Start: ./services/service-manager.sh start database

πŸ“Š Service Management

Service Commands

# Start services
./services/service-manager.sh start [service]
./services/service-manager.sh start all
./services/service-manager.sh start backend
./services/service-manager.sh start frontend

# Stop services
./services/service-manager.sh stop [service]
./services/service-manager.sh stop all

# Restart services
./services/service-manager.sh restart [service]
./services/service-manager.sh restart all

# Check status
./services/service-manager.sh status

Docker Commands

# Start all services
docker-compose up -d

# Start specific service
docker-compose up -d backend

# View logs
docker-compose logs -f backend

# Stop all services
docker-compose down

# Rebuild services
docker-compose build --no-cache

πŸ”§ Configuration

Each service has its own configuration file:

  • services/backend/config.ini - Backend service config
  • services/frontend/config.ini - Frontend service config
  • services/notification-engine/config.ini - Engine config
  • services/database/config.ini - Database config

πŸ“± Access Points

πŸŽ‰ Features

πŸ—οΈ Architecture & Infrastructure

  • βœ… Service-oriented architecture
  • βœ… Multi-tenant support with separate schemas
  • βœ… Docker containerization
  • βœ… Unified notification system
  • βœ… Service management tools
  • βœ… Health checks and monitoring
  • βœ… Scalable and maintainable

🎨 User Interface & Experience

  • βœ… Modern glass-morphism UI design
  • βœ… WhatsApp-like React interface
  • βœ… Company switching with dynamic themes
  • βœ… Real-time notifications with beautiful animations
  • βœ… Analytics dashboard with comprehensive metrics
  • βœ… Responsive design for all devices

⚑ Real-Time & Performance

  • βœ… Real-time PostgreSQL notifications
  • βœ… WebSocket connections with robust error handling
  • βœ… Multi-tenant notification routing
  • βœ… Enhanced notification payloads
  • βœ… No artificial API limits (shows ALL data)
  • βœ… Optimized database queries

πŸ“Š Data & Analytics

  • βœ… Enhanced data generation with Faker
  • βœ… Realistic test data across multiple industries
  • βœ… Comprehensive analytics metrics
  • βœ… Multi-locale support (US, GB, CA, AU)
  • βœ… Rich metadata with location, device, browser info
  • βœ… Intelligent data distribution patterns

🎭 Data Generation & Testing

Enhanced Data Generation with Faker

# Generate realistic test data for all companies
make generate

# Generate data for specific companies
make generate-alpha    # TechFlow Solutions
make generate-beta     # SocialMedia Pro  
make generate-gamma    # OmniChannel Corp

# Generate large datasets
make generate-large

Data Generation Features

  • Realistic User Data: International phone numbers, emails, social media handles
  • Industry-Specific Content: Technology, Social Media Marketing, E-commerce
  • Intelligent Distribution: Recent bias, weekday patterns, status distribution
  • Rich Metadata: Location, device, browser, customer tier information
  • Multi-Locale Support: US, GB, CA, AU locales for diverse data

Testing Commands

# Test the system
make test

# Check service status
make status

# View logs
make logs

πŸš€ Development

Local Development

# Start multi-tenant services
make start-multi

# Generate test data
make generate

# Access unified frontend
open http://localhost:3000

Production Deployment

# Use Docker Compose
docker-compose up -d

Service Monitoring

# Check service status
./services/service-manager.sh status

# View service logs
docker-compose logs -f [service]

πŸ“š Documentation

Your PostgreSQL notification system now features a modern multi-tenant architecture with enhanced data generation and beautiful UI! πŸš€

About

A complete real-time notification system using PostgreSQL LISTEN/NOTIFY with a modern service-oriented architecture, multi-tenant support, and enhanced data generation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published