Report this

What is the reason for this report?

How to build subscription application with own instance

Posted on March 1, 2021

My question title may not appropriate as I am not so aware of how to call it. I will appreciate it if anyone can edit to fits the query.

I am planning to build a web application where users will subscribe. For instance, CRM or Project management application. I want to have a separate instance and database with a custom domain for enterprise subscribers, and I may have a common database or instance for non-enterprise subscribers. The subscription will be handled through a marketing website, where all subscribers will checkout and have their own account.

  • Marketing website to subscribe
  • Application instance / website/ database / etc

Once the subscription period is over and it is not renewed, they will lose access. If they do not renew/reactivate for x time, the instance will destroy itself.

I am quite confident with PHP and MySQL, have some knowledge of AWS and Digital Ocean. I am planning to use Laravel for serverside. However, I am open to other languages as well, such as python.`

Can anyone help me to learn the best approach for the system I want to make. Pros and Cons and things to be considered? Also, approach to make a mobile application for the subscriber where they can access their own instance.

Also, find here https://stackoverflow.com/q/66419485/1053190



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

I have also been using Laravel for a while now and I believe that it is a great choice for building a SaaS project.

I’ve been quite happy with Laravel Wave as it comes with out of the box Authentication, Subscriptions, Invoices, Announcements, User Profiles, API, and etc. That way you could focus only on the functionality.

Hope that this helps! Regards, Bobby

Building a subscription-based application with dedicated instances for enterprise subscribers and a shared environment for non-enterprise subscribers requires careful planning and architecture. Below is a step-by-step guide and considerations to help you get started:


1. Architecture Overview

Key Components:

  1. Marketing Website:

    • Handles subscriptions, billing, and account management.
    • Should integrate with a payment gateway (Stripe, PayPal, etc.).
    • Technology: Laravel, Django, or any framework you’re comfortable with.
  2. Application Instances:

    • Enterprise Subscribers:
      • Each gets their own dedicated instance (isolated app and database).
      • Example: company1.yourapp.com, company2.yourapp.com.
    • Non-Enterprise Subscribers:
      • Shared instance with multi-tenancy (single database with tenant segregation).
  3. Automation Layer:

    • Manages the provisioning of new instances (e.g., Docker, Kubernetes, or Ansible scripts).
    • Deletes expired instances after a grace period.
  4. Database Design:

    • Shared Database for Non-Enterprise Users:
      • Use tenant ID or similar identifier for segregating data.
    • Dedicated Databases for Enterprise Users:
      • Separate database per enterprise for scalability and data isolation.
  5. Mobile Application:

    • Mobile apps can authenticate via an API and access the user’s instance.

2. Steps to Build the System

A. Subscription Flow

  1. Marketing Website:

    • Create a central portal where users can:
      • Register and subscribe to plans.
      • Manage subscriptions and billing (via Stripe, PayPal, etc.).
    • Store user details in a central database.
  2. Plan Differentiation:

    • Define two subscription plans:
      • Enterprise Plan: Provisions a new dedicated instance.
      • Non-Enterprise Plan: Maps the user to the shared instance.
  3. Instance Management:

    • Automate instance creation using cloud provider APIs (e.g., AWS, DigitalOcean).
    • Use tools like Terraform or Docker for infrastructure as code.

B. Instance Provisioning

  1. For Enterprise Users:

    • Deploy a new Laravel application with its own database.
    • Use subdomains or custom domains (e.g., company1.yourapp.com).
    • Automate the provisioning via:
      • Laravel Forge for Laravel-specific deployments.
      • Docker containers for isolated environments.
      • Kubernetes for orchestration and scalability.
  2. For Non-Enterprise Users:


C. Billing and Subscription

  1. Payment Gateway Integration:

    • Use Laravel Cashier for Stripe or Paddle.
    • Automate billing cycles and handle retries for failed payments.
  2. Access Control:

    • Implement middleware to check subscription status.
    • Block access if the subscription is expired.
  3. Instance Cleanup:

    • Use background jobs or cron to:
      • Delete instances and databases for expired subscriptions after a grace period.

D. Mobile Application

  1. API-First Approach:

    • Build a RESTful API or GraphQL for your Laravel app.
    • Mobile apps (React Native, Flutter, etc.) will communicate via this API.
  2. Tenant Identification:

    • For enterprise users, API requests should include tenant-specific subdomain or token.
    • For non-enterprise users, tenant ID should identify the user.

3. Tools and Technologies

Component Recommended Tools
Frontend React.js, Vue.js, or Laravel Blade
Backend Laravel, Django, or Flask
Database MySQL, PostgreSQL
Mobile App React Native, Flutter
Payment Gateway Stripe, PayPal, Paddle
Automation/Provisioning Terraform, Ansible, Docker, Kubernetes
Cloud Hosting AWS, DigitalOcean, Google Cloud, Linode

4. Pros and Cons

Approach Pros Cons
Dedicated Instances - Full data isolation
  • Scalability
  • Easier compliance | - Higher cost
  • Complex automation | | Shared Instance | - Lower cost
  • Simpler management | - Risk of data leaks
  • Performance bottlenecks |

5. Key Considerations

  1. Scalability:

    • Plan for horizontal scaling (e.g., load balancers, Kubernetes).
    • Use caching (e.g., Redis) to improve performance.
  2. Data Security:

    • Encrypt sensitive data.
    • Isolate enterprise databases for compliance.
  3. Monitoring and Maintenance:

    • Monitor server health (e.g., Prometheus, Grafana).
    • Automate backups for databases.
  4. Graceful Downtime Handling:

    • Notify users before deleting expired instances.
    • Allow data export options.

6. Suggested Roadmap

  1. Start with a shared instance for MVP.
  2. Introduce enterprise plans with dedicated instances after validating the demand.
  3. Add a mobile app with API integration.
  4. Implement automation for scaling and cleanup.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.