Skip to main content

Account Service

Managing organizations, subscriptions, and billing.

Overview

The Account Service is responsible for the multi-tenant aspects of LibreApps Desktop. It manages the lifecycle of organizational accounts, their subscription plans, and their billing status.

Key Responsibilities

  • Organization Management: Handles the creation and configuration of organizational accounts.
  • Subscription Management: Tracks which plan an organization is on (e.g., Free, Pro, Enterprise).
  • Billing Integration: Communicates with payment providers (e.g., Stripe) to handle invoices and payments.
  • Usage Quotas: Monitors and enforces usage limits based on the organization's subscription plan.
  • Team Management: Allows organization admins to invite and manage team members.

API Endpoints

GET /api/accounts/current

Retrieves the details of the organization the current user belongs to.

POST /api/accounts/create

Creates a new organizational account.

PUT /api/accounts/subscription

Updates the subscription plan for an organization.

GET /api/accounts/billing/history

Retrieves the billing history and invoices for an organization.

Database Schema

The service uses a PostgreSQL database with tables such as:

  • accounts: Stores organization details.
  • subscriptions: Tracks active subscription plans.
  • billing_records: Stores payment and invoice history.

Best Practices

  • Do this: Use the Account Service to enforce multi-tenancy and ensure that users can only access data belonging to their organization.
  • Do this: Implement robust error handling for billing operations to avoid payment issues.
  • Don't do this: Store credit card information directly in your database; always use a secure payment provider like Stripe.