Skip to content

gajanansr/loopin-spring

Repository files navigation

πŸ’¬ Loopin Backend

A secure, scalable Spring Boot backend for a modern messaging platform with subscription-based channels. Built for high-performance real-time communication with integrated payment processing.

Java Spring Boot PostgreSQL Redis License

πŸš€ Quick Start

Prerequisites

  • Java 21+
  • Docker & Docker Compose
  • PostgreSQL 15+
  • Redis 7+

Setup Instructions

# Clone the repository
git clone https://github.com/your-org/loopin-backend.git
cd loopin-backend

# Start dependencies with Docker Compose
docker-compose up -d postgres redis

# Configure environment variables
cp .env.example .env
# Edit .env with your configuration

# Run the application
./gradlew bootRun

Environment Variables

# Database Configuration
DATABASE_URL=jdbc:postgresql://localhost:5432/loopchat
DATABASE_USERNAME=loopchat
DATABASE_PASSWORD=your_password

# Redis Configuration
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=

# JWT Configuration
JWT_SECRET=your_jwt_secret_key
JWT_EXPIRATION=86400000

# Razorpay Configuration
RAZORPAY_KEY_ID=your_razorpay_key_id
RAZORPAY_KEY_SECRET=your_razorpay_key_secret
RAZORPAY_WEBHOOK_SECRET=your_webhook_secret

# AWS S3 Configuration (Optional)
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_S3_BUCKET=your_bucket_name
AWS_REGION=us-east-1

🎯 Key Features

πŸ” Secure Authentication

  • JWT-based authentication with automatic refresh
  • Single-device login enforcement
  • Device fingerprinting for enhanced security
  • Secure password reset flow

πŸ’¬ Real-Time Messaging

  • WebSocket-based instant messaging
  • Message delivery confirmations
  • Typing indicators and read receipts
  • Offline message queuing

πŸ“Ί Subscription Channels

  • Create paid and free channels
  • Razorpay integration for payments
  • Creator payout system
  • Subscriber management

πŸ“ Media Handling

  • Secure file uploads to S3/MinIO
  • Image compression and optimization
  • CDN integration for fast delivery
  • Multiple file format support

πŸ“Š Analytics & Monitoring

  • Real-time system metrics
  • Business analytics dashboard
  • Payment transaction tracking
  • User engagement insights

πŸ—οΈ Architecture

Technology Stack

  • Backend: Spring Boot 3.x with WebFlux (Reactive)
  • Database: PostgreSQL with Redis caching
  • Authentication: JWT with RS256 signing
  • Payments: Razorpay integration
  • Storage: AWS S3 or MinIO
  • Real-time: WebSocket/STOMP protocol

Project Structure

src/main/java/com/loopchat/
β”œβ”€β”€ auth/           # Authentication & user management
β”œβ”€β”€ messaging/      # Real-time messaging system
β”œβ”€β”€ channels/       # Channel management & subscriptions
β”œβ”€β”€ payments/       # Razorpay payment processing
β”œβ”€β”€ media/          # File upload & storage
β”œβ”€β”€ config/         # Spring configurations
β”œβ”€β”€ security/       # Security configurations
└── common/         # Shared utilities & DTOs

πŸ“– Documentation

Document Description
πŸ”§ GitHub Copilot Instructions Complete guide for AI-assisted development
πŸ“‹ Feature Documentation Detailed feature specifications
πŸ—οΈ Architecture Guide System architecture and design patterns
πŸ”Œ API Documentation RESTful API endpoints and WebSocket events
πŸ›‘οΈ Security Guidelines Security best practices and implementation
πŸš€ Deployment Guide Production deployment instructions

πŸ”Œ API Overview

Authentication Endpoints

POST /api/v1/auth/register      # User registration
POST /api/v1/auth/login         # User login
POST /api/v1/auth/refresh       # Token refresh
POST /api/v1/auth/logout        # User logout

Messaging Endpoints

GET  /api/v1/conversations               # List conversations
POST /api/v1/conversations/{id}/messages # Send message
WS   /ws/chat                           # WebSocket connection

Channel Endpoints

GET  /api/v1/channels                # List all channels
POST /api/v1/channels                # Create new channel
POST /api/v1/channels/{id}/subscribe # Subscribe to channel

Payment Endpoints

POST /api/v1/payments/orders    # Create payment order
POST /api/v1/payments/verify    # Verify payment
POST /api/v1/payments/webhooks  # Razorpay webhooks

πŸ§ͺ Testing

Run Tests

# Unit tests
./gradlew test

# Integration tests
./gradlew integrationTest

# Test coverage report
./gradlew jacocoTestReport

Test Configuration

  • Unit Tests: JUnit 5 + Mockito
  • Integration Tests: TestContainers for database
  • WebSocket Tests: Spring WebSocket Test
  • Coverage: JaCoCo with 80% minimum coverage

πŸš€ Deployment

Docker Deployment

# Build Docker image
docker build -t loopchat-backend .

# Run with Docker Compose
docker-compose up -d

Production Checklist

  • Environment variables configured
  • Database migrations applied
  • SSL certificates installed
  • Monitoring tools configured
  • Backup strategy implemented
  • Rate limiting configured

πŸ”§ Development

Prerequisites for Contributors

  • Java 21+ (OpenJDK recommended)
  • IntelliJ IDEA or VS Code
  • Docker for local dependencies
  • Postman for API testing

Development Workflow

  1. Setup: Follow quick start instructions
  2. Branch: Create feature branch from main
  3. Code: Follow architectural guidelines
  4. Test: Write comprehensive tests
  5. Review: Submit pull request for review
  6. Deploy: Merge to main triggers deployment

Code Style

  • Follow Spring Boot conventions
  • Use meaningful variable names
  • Document public APIs with JavaDoc
  • Implement proper error handling
  • Add comprehensive logging

πŸ“Š Monitoring

Health Endpoints

GET /actuator/health     # Application health
GET /actuator/metrics    # Application metrics
GET /actuator/info       # Application info

Key Metrics

  • Performance: API response times, throughput
  • Business: Messages sent, payments processed, active users
  • System: JVM metrics, database connections, cache hit rates
  • Security: Failed logins, rate limit hits, suspicious activities

🀝 Contributing

We welcome contributions! Please read our Contributing Guidelines for details on:

  • Code of conduct
  • Development process
  • Pull request process
  • Coding standards

Getting Started with Contributions

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

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

πŸ†˜ Support

Documentation

Getting Help

  • πŸ› Bug Reports: Use GitHub Issues
  • πŸ’‘ Feature Requests: Use GitHub Discussions
  • πŸ“§ Security Issues: Email security@loopchat.com
  • πŸ’¬ General Questions: Join our Discord community

Status

  • βœ… MVP Features: Authentication, Messaging, Payments
  • πŸ”„ In Development: Group chat, Voice messages
  • πŸ“‹ Planned: E2E encryption, Analytics dashboard

Built with ❀️ for secure, scalable messaging by Gajanan Rathod

About

Loopin is a modern messaging platform that combines real-time chat with subscription-based channels. Think Telegram meets premium content subscriptions.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages