Kulcare Docs
DeveloperReports

Reports App - Micro-Frontend

Overview

The Reports app is a dedicated micro-frontend for premium reporting features including:

  • Consolidated reports across multiple locations
  • Commission tracking and management for doctors/consultants
  • Revenue sharing configuration and tracking

Status: ✅ Complete and ready for production

Architecture

Micro-Frontend Integration

The Reports app follows the same micro-frontend pattern as CMS and Growth apps:

// Shell app lazy loads Reports app
const ReportsApp = lazy(() => import('@kulcare/reports/src/App'))

// Routes in shell
<Route path="/reports/*" element={<ReportsApp />} />

Development-Only Mock Data

The app includes comprehensive mock data for development that is:

  • Excluded from production builds using dynamic imports
  • Conditionally loaded based on environment variables
  • Type-safe with full TypeScript support
// API service with conditional mock loading
export const reportsApi = {
  async getConsolidatedReports(params) {
    if (import.meta.env.DEV && !import.meta.env.VITE_USE_REAL_API) {
      const { mockConsolidatedReports } = await import('./__mocks__/mockReportsData')
      return mockConsolidatedReports(params)
    }
    return apiClient.get('/reports/consolidated', { params })
  }
}

Features

1. Dashboard

  • Overview of all reporting features
  • Quick stats for revenue, commissions, and payouts
  • Navigation to specific report sections

2. Consolidated Reports

  • Revenue Analysis: Daily/weekly/monthly revenue trends
  • Appointment Metrics: Completion rates, cancellations, no-shows
  • Patient Demographics: Age, gender distribution, top conditions
  • Location Performance: Comparative analysis across clinics
  • Export Options: PDF, Excel, CSV formats

3. Commission Tracking

  • Rule Management: Configure commission rules (percentage, tiered, performance-based)
  • Calculations: Automated commission calculations with manual adjustments
  • Approval Workflow: Multi-step approval process with audit trail
  • Payout Processing: Batch payout with multiple payment methods
  • Analytics: Commission trends, top earners, role-based analysis

4. Revenue Sharing

  • Configuration Management: Define stakeholder shares per location
  • Automated Distribution: Calculate revenue shares based on configurations
  • Payout Tracking: Monitor pending and completed payouts
  • Trend Analysis: Revenue trends with growth metrics
  • Stakeholder Management: Track individual stakeholder payouts

API Services

Reports API (reportsApi)

- getConsolidatedReports(params)
- getSavedReports()
- exportReport(reportId, format)
- generateReport(params)
- deleteReport(reportId)
- getReportTemplates()

Commissions API (commissionsApi)

- getCommissionRules(filters)
- createCommissionRule(ruleData)
- updateCommissionRule(ruleId, updates)
- getCommissionCalculations(params)
- runCommissionCalculation(params)
- approveCommission(calculationId, notes)
- processPayout(calculationIds, paymentMethod)
- getCommissionAnalytics(params)

Revenue API (revenueApi)

- getRevenueSharingConfigs(locationId)
- createRevenueSharingConfig(configData)
- updateRevenueSharingConfig(configId, updates)
- getRevenueSharingCalculations(params)
- getRevenueTrends(params)
- getStakeholderPayouts(params)
- processRevenueSharingPayout(payoutIds, paymentDetails)

Mock Data Structure

Reports Mock Data

  • Time series revenue data
  • Appointment statistics
  • Patient demographics
  • Location-wise breakdowns

Commission Mock Data

  • Commission rules (percentage, tiered, performance)
  • User commission calculations
  • Approval workflows
  • Payout history

Revenue Mock Data

  • Revenue sharing configurations
  • Stakeholder distributions
  • Payout tracking
  • Trend analysis

Environment Configuration

# Use real API instead of mocks
VITE_USE_REAL_API=true

# API endpoint
VITE_API_URL=https://api.kulcare.com

Development

Running Standalone

cd apps/reports
pnpm dev
# Opens at http://localhost:3004

Running with Shell

pnpm dev
# Access via shell at http://localhost:3000/reports

Building for Production

pnpm build --filter=@kulcare/reports

Feature Flags

The Reports app visibility is controlled by feature flags in the shell:

  • ENABLE_CONSOLIDATED_REPORTS
  • ENABLE_REVENUE_SHARING
  • ENABLE_COMMISSION_TRACKING

Any of these flags being true will enable the Reports app in navigation.

Role-Based Access

  • Admin/Owner: Full access to all features
  • Doctor/Consultant: Limited to viewing their own commission data
  • Staff: Access based on specific permissions

UI Components

Charts and Visualizations

  • Line charts for trends (Recharts)
  • Bar charts for comparisons
  • Pie charts for distributions
  • Tables with sorting and filtering

Forms and Modals

  • Commission rule configuration
  • Revenue sharing setup
  • Date range pickers
  • Export dialogs

Status Indicators

  • Badge components for statuses
  • Progress indicators for calculations
  • Real-time updates for job progress

Testing

Unit Tests

pnpm test --filter=@kulcare/reports

Manual Testing

  1. Verify mock data loads in development
  2. Confirm mocks are excluded from production build
  3. Test all CRUD operations with mock data
  4. Verify exports work correctly
  5. Test navigation between sections

Production Readiness

✅ Completed:

  • Fully functional UI with all features
  • Comprehensive mock data system
  • Development-only mock loading
  • API service layer ready for integration
  • Role-based access controls
  • Export functionality
  • Responsive design

⏳ Pending (Backend required):

  • Real API endpoints implementation
  • Authentication integration
  • Real-time updates
  • File download for exports

V2 Features (Coming Soon)

🚧 Advanced Analytics Dashboard

Status: Coming Soon

Enhanced analytics capabilities:

  • AI-Powered Insights: Machine learning algorithms to identify trends and anomalies
  • Predictive Forecasting: Revenue and patient flow predictions
  • Custom KPI Builder: Create and track custom key performance indicators
  • Automated Alerts: Smart notifications for significant changes
  • Benchmarking: Compare performance against industry standards

🚧 Real-Time Reporting

Status: Coming Soon

Live data streaming and updates:

  • WebSocket Integration: Real-time data synchronization
  • Live Dashboards: Auto-updating metrics and charts
  • Instant Notifications: Push alerts for critical events
  • Collaborative Viewing: Multiple users can view reports simultaneously
  • Activity Feed: Real-time stream of financial activities

🚧 Custom Report Builder

Status: Coming Soon

Self-service report creation:

  • Drag-and-Drop Designer: Visual report builder interface
  • Template Library: Pre-built templates for common reports
  • Custom Calculations: Create complex formulas and metrics
  • Scheduled Reports: Automated generation and delivery
  • Report Sharing: Secure sharing with stakeholders

🚧 Mobile Reports App

Status: Coming Soon

Native mobile experience:

  • iOS and Android Apps: Native applications for better performance
  • Offline Mode: Download and view reports without internet
  • Touch-Optimized: Gestures for zooming and navigation
  • Biometric Security: Face ID/Touch ID authentication
  • Push Notifications: Real-time alerts on mobile

🚧 Integration Hub

Status: Coming Soon

Third-party integrations:

  • QuickBooks Integration: Sync financial data automatically
  • Payment Gateways: Stripe, Razorpay, PayPal analytics
  • Google Analytics: Website traffic correlation with revenue
  • SMS/WhatsApp: Automated report delivery via messaging
  • API Marketplace: Connect with any third-party service

🚧 Compliance & Audit

Status: Coming Soon

Enhanced compliance features:

  • Regulatory Reports: GST, tax, and compliance reports
  • Audit Trail Enhancement: Blockchain-based immutable logs
  • Digital Signatures: Legally binding report approvals
  • Role-Based Restrictions: Granular permission controls
  • Data Retention Policies: Automated archival and purging

On this page