Skip to content
All posts

Multi-Tenant SaaS in Django: The Reseller Model Behind Raseed Pro

How we built Raseed Pro as a multi-tenant SaaS in Django: an Organization and Company model, reseller accounts, per-seat billing and subscription enforcement.

Muhammad ArslanCo-FounderPublished

When we set out to build Raseed Pro, an FBR digital-invoicing platform for Pakistani businesses, we knew early on that it would not be sold one way. Some customers would sign up on their own. Others would come through tax consultants and resellers who manage dozens of client businesses at once. That one requirement shaped the whole architecture: Raseed Pro had to be a multi-tenant SaaS in Django with a reseller model built in from day one.

This post walks through how we designed it: the data model, how tenants and resellers fit together, how seats and billing work, and the lessons we would share with anyone building a multi-tenant product on Django.

What "multi-tenant" means for Raseed Pro

In a multi-tenant SaaS, many customers share one application and one infrastructure, but each customer's data stays strictly separate. For Raseed Pro, the "customer" is not a single shape, though:

  • Direct customers: a business signs up, starts a free trial and issues its own FBR invoices.
  • Resellers (tenants): a tax consultancy or partner manages many client businesses, each with its own NTN, its own FBR token and its own users.

Both need to live in the same system, on the same code, without special-casing every feature.

The data model: Organization and Company

The core decision was to separate who pays from who invoices:

  • Organization is the paying party. It owns the subscription, the plan, the seats and the billing history.
  • Company is one NTN, one taxpayer. It holds the FBR tokens, buyers, sellers, products and invoices. A Company always belongs to exactly one Organization.

A direct customer is simply an Organization with one Company. A reseller is an Organization with many Companies. The invoicing code never needs to know which kind it is dealing with: it works on a Company, and the Company knows its Organization.

Users connect through memberships. A user can be a member of an Organization (for example, a consultant's staff) or of a specific Company (for example, a client's accountant). One login can open several workspaces, and each workspace is one NTN with its own FBR token.

Two ways in: self-serve and reseller onboarding

Self-serve sign-up

A direct customer registers through a single API call. In one transaction, Django creates the user, the Organization, the first Company and a trial subscription on a public plan. The pricing page reads the same plans from the API, so marketing and billing never drift apart.

Reseller accounts

Resellers are created by a super admin with negotiated terms: a custom price per user and, optionally, a price per company. From there, the reseller works inside its own organization-scoped endpoints to create client companies and users, see usage, check the next charge and review billing history. Consultants can do the IRIS setup and FBR scenario testing for each client, then hand over a working login.

Seats: defining what you bill for

Per-user pricing only works if "a user" is defined precisely. In Raseed Pro, a billable seat is an enabled user with an active membership on the Organization or on any of its Companies. A person who works across ten client companies is still one seat.

Organization admins can list seats and deactivate or reactivate a user across the whole organization in one step. That keeps the bill predictable for resellers and keeps access control in one place.

Enforcement without breaking access

When a subscription lapses, the worst outcome is locking customers out of their own data. Our rule is simple:

  • Reads always work. Customers can view and export their invoices at any time.
  • Writes pause. Creating or changing invoices, master data or FBR actions returns HTTP 402 (Payment Required) until the subscription is usable again.

Because the check lives in one place, at the permission layer, every company-scoped endpoint gets it for free. New features cannot accidentally bypass billing.

Billing: simple first, gateway later

We deliberately kept billing simple for launch:

  • Issue invoice: snapshots seats and companies for the billing period.
  • Mark paid: records a bank transfer or manual payment and rolls the period forward.
  • Daily billing tick: a scheduled management command flags expired periods as past due.

Payment gateway integration is designed as a later adapter, so the billing logic does not depend on any one provider.

What is shared and what is isolated

Not everything in a multi-tenant system should be per-tenant. FBR's reference data (HS codes, units of measure, sale types, tax rates and SRO schedules) is the same for everyone, so it is stored once, globally, and synced from FBR on a schedule. Everything that belongs to a taxpayer is isolated per Company:

  • FBR sandbox and production tokens, stored encrypted at rest
  • Buyers, sellers and products
  • Invoices, activity logs and exports

Getting this split right kept the database lean and made adding a new client company instant: there is nothing to copy or sync per tenant.

The stack

  • Backend: Django with Django REST Framework, API-only, JWT authentication
  • Frontend: React, TypeScript, Redux Toolkit and RTK Query
  • Infrastructure: AWS, with Nginx, Gunicorn and systemd timers for scheduled jobs
  • PDFs: WeasyPrint for FBR-compliant invoices with QR codes

Lessons for building multi-tenant SaaS in Django

  1. Separate the payer from the workspace. An Organization/Company split makes direct sales and reseller sales the same code path.
  2. Define a seat precisely before you price per user. Ambiguity here becomes billing disputes later.
  3. Enforce subscriptions in one layer. Put the check in permissions, not in each view.
  4. Never lock customers out of reading their own data. Pause writes, not reads.
  5. Keep global reference data global. Not everything needs a tenant key.
  6. Encrypt tenant secrets. API tokens belong in encrypted fields, not plain text.

Building a multi-tenant SaaS? Let's talk

At ThunderMind Tech, we design and build SaaS products like Raseed Pro end to end, from multi-tenant architecture and billing to government API integrations and production deployment. If you are planning a multi-tenant platform, a reseller model or a Django product that needs to scale, we would be glad to help.

👉 Contact us to discuss your project or hire our team.

Written byMuhammad ArslanCo-Founder
// Keep reading

More from the blog

6 min read

Lessons from Two Years on MIT Open Learning's Open edX Platforms

Two years, 170+ pull requests and a lot of production lessons: what working on MIT Open Learning's Open edX platforms taught us about Open edX development, plugins, MFEs and upstream contributions.

DjangoEdTechEngineeringLMS DevelopmentOpen SourceOpen edXOpen edX developmentPythonMuhammad Arslan
4 min read

Building ElectCrew: a canvassing app that never sends a message itself

ElectCrew is our canvassing app for bar and membership elections. Here is why it hands every call and message to the candidate's own phone, and how we keep a member roll from leaking.

Bar association electionsData privacyElectCrewElection canvassing appMuhammad Arslan
8 min read

How We Built Raseed Pro’s FBR Integration on Django

When FBR made digital invoicing mandatory, Raseed Pro had to keep up without slowing down a single checkout. Here’s how we built a fast, secure, and failure-proof Django FBR integration using Celery, encrypted tokens, and smart retry logic, plus the lessons we learned along the way.

DjangoDjango invoicing systemFBR POS integrationFBR digital invoicing APIMuhammad Arslan

Have a project in mind?

Tell us what you're building. A co-founder replies within one business day.