Business Module Documentation
The Business module manages end customers who purchase and use the platform's software products (ERP, SACCO, Payroll systems). This module handles customer onboarding, subscription management, and product access.
Module Overview
Purpose
The Business module serves as the customer-facing component of the Evolve Platform, handling:
- Customer registration and profile management
- Software product subscriptions and billing
- Product access and usage tracking
- Customer support and communication
- Integration with payment systems
Directory Structure
App/business/
App/business/
├── __init__.py
├── admin.py # Django admin configuration
├── apps.py # App configuration
├── models.py # Business data models
├── views.py # Business view controllers
├── urls.py # URL routing
├── serializers.py # API serializers
├── forms.py # Django forms
├── managers.py # Custom model managers
├── utils.py # Business utility functions
├── signals.py # Django signals
├── tasks.py # Background tasks
├── tests/
│ ├── test_models.py # Model tests
│ ├── test_views.py # View tests
│ ├── test_api.py # API tests
│ └── test_utils.py # Utility tests
├── management/
│ └── commands/ # Management commands
├── migrations/ # Database migrations
└── templates/business/ # Business templates
Key Responsibilities
Customer Management
- Registration: Handle new business customer sign-ups
- Profile Management: Manage company information and user profiles
- Verification: Verify business credentials and documentation
- KYC Compliance: Ensure know-your-customer compliance
Subscription Management
- Plan Selection: Allow customers to choose subscription plans
- Billing Cycles: Manage monthly/yearly billing cycles
- Payment Processing: Handle subscription payments
- Plan Changes: Support upgrades and downgrades
Product Access
- Feature Access: Control access to product features based on plan
- Usage Tracking: Monitor product usage and limits
- Multi-tenant Support: Ensure data isolation between customers
Core Models
Business Model
Main model representing business customers:
class Business(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
business_name = models.CharField(max_length=200)
business_email = models.EmailField()
industry = models.CharField(max_length=100)
company_size = models.CharField(max_length=20)
country = models.CharField(max_length=50)
postal_code = models.CharField(max_length=20)
subscription_status = models.CharField(max_length=20)
created_at = models.DateTimeField(auto_now_add=True)
Subscription Model
Manages customer subscriptions:
class Subscription(models.Model):
business = models.ForeignKey(Business, on_delete=models.CASCADE)
plan = models.ForeignKey(Plan, on_delete=models.CASCADE)
status = models.CharField(max_length=20)
start_date = models.DateTimeField()
end_date = models.DateTimeField()
auto_renewal = models.BooleanField(default=True)
Plan Model
Defines available subscription plans:
class Plan(models.Model):
name = models.CharField(max_length=100)
price = models.DecimalField(max_digits=10, decimal_places=2)
yearly_price = models.DecimalField(max_digits=10, decimal_places=2)
description = models.TextField()
features = models.JSONField()
max_users = models.IntegerField()
storage_limit = models.BigIntegerField()
API Endpoints
Business Profile APIs
Method | Endpoint | Description |
---|---|---|
GET | /api/business/v1/profile/ | Get business profile |
PUT | /api/business/v1/profile/ | Update business profile |
POST | /api/business/v1/verify/ | Submit verification documents |
Subscription APIs
Method | Endpoint | Description |
---|---|---|
GET | /api/business/v1/subscription/ | Get current subscription |
GET | /api/business/v1/plans/ | List available plans |
POST | /api/business/v1/subscribe/ | Subscribe to a plan |
PUT | /api/business/v1/subscription/change/ | Change subscription plan |
POST | /api/business/v1/subscription/cancel/ | Cancel subscription |
Usage & Billing APIs
Method | Endpoint | Description |
---|---|---|
GET | /api/business/v1/usage/ | Get usage statistics |
GET | /api/business/v1/invoices/ | List invoices |
GET | /api/business/v1/payments/ | List payment history |
Service Layer
Business Services
- CustomerService: Handles customer registration and verification
- SubscriptionService: Manages subscription lifecycle
- BillingService: Handles billing and payment processing
- UsageTrackingService: Monitors product usage and limits
- NotificationService: Sends customer notifications
Development Guidelines
Adding New Features
- Always consider multi-tenancy when adding new features
- Implement proper access controls and permissions
- Add usage tracking for billable features
- Ensure backward compatibility with existing subscriptions
Billing and Payments
- Always use transactions for billing operations
- Implement idempotency for payment operations
- Log all financial transactions for audit purposes
- Handle payment failures gracefully
Data Security
- Encrypt sensitive business data at rest
- Implement proper data isolation between customers
- Regular security audits and penetration testing
- GDPR compliance for data protection
Testing
- Write comprehensive tests for billing logic
- Test multi-tenant data isolation
- Mock external payment services in tests
- Load test subscription management endpoints
Important: The Business module handles critical customer data and billing operations. All changes should be thoroughly tested and reviewed before deployment. Consider the financial and operational impact of any modifications.