Skip to content

sivakumar07/saas-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi‑Tenant SaaS Application

This project demonstrates a multi‑tenant SaaS platform built with Spring Boot, PostgreSQL, Redis and Rqueue for asynchronous task processing. It supports tenant sign‑up, JWT authentication, CRUD operations on contacts, soft deletion with audit logging, sharded databases and background tasks. Database schemas are managed using Liquibase for both the central database and each shard.

Prerequisites

  • Java 17 or higher
  • Maven 3.8+
  • PostgreSQL 13+ with databases created for the central schema and one or more shards. By default the application expects databases named central_db, shard1_db and shard2_db on localhost with username/password postgres/postgres. Adjust src/main/resources/application.yml as needed.
  • Redis 6+. An embedded Redis server is started automatically on port 6379 if none is available. For production use, configure spring.redis.host and spring.redis.port to point to an external Redis instance.

Bootstrapping the Application

  1. Initialize the databases. Ensure the central and shard databases exist. Liquibase will create the required tables on first run:

    psql -U postgres -c 'CREATE DATABASE central_db;'
    psql -U postgres -c 'CREATE DATABASE shard1_db;'
    psql -U postgres -c 'CREATE DATABASE shard2_db;'
  2. Build the project. From the saas-app directory run:

    mvn clean package

    This compiles the application, runs the tests and packages an executable JAR in target/.

Running the Application

The application can be run in different modes depending on your needs.

Default Mode (Web + Worker)

This is the standard mode for development. It runs the web application and the Rqueue message workers in the same process.

java -jar target/saas-app-*.jar

Web-Only Mode

This mode runs the web application without the Rqueue message workers. This is useful for running a dedicated web server instance.

java -jar target/saas-app-*.jar --spring.profiles.active=web

Worker-Only Mode

This mode runs only the Rqueue message workers, without the web server. This is ideal for running dedicated, scalable worker instances.

java -jar target/saas-app-*.jar --spring.profiles.active=worker

Worker for a Specific Queue

To run a worker that only processes specific queues, you can use the rqueue.queues property. For example, to run a worker that only processes the testQueue:

java -jar target/saas-app-*.jar --spring.profiles.active=worker --rqueue.queues=testQueue

You can also specify multiple queues as a comma-separated list:

java -jar target/saas-app-*.jar --spring.profiles.active=worker --rqueue.queues=testQueue,contactEventQueue

API Endpoints

Swagger UI is available at http://localhost:8080/swagger-ui.html for detailed API documentation and testing.

Rqueue Dashboard

The Rqueue dashboard is available at http://localhost:8080/rqueue for monitoring and managing message queues.

Testing

Running Tests

To run the unit and integration tests, use the following Maven command:

mvn test

Test Coverage Report

This project uses the JaCoCo plugin to generate test coverage reports. To generate the report, run the following command:

mvn clean verify

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages