--- name: integrated-crm-app version: 1.0.0 description: Complete integrated CRM application combining customer management, contract management, opportunity management, financial management, appbase foundation, and RBAC security modules into a unified web application. trigger_conditions: - User requests to create an integrated CRM system - Task involves combining multiple business modules into a single application - Need unified interface for customer, contract, opportunity, and financial management - Require RBAC security and appbase foundation integration --- # Integrated CRM Application ## Overview This skill provides a complete, production-ready integrated CRM application that seamlessly combines six core modules into a unified web interface: 1. **Customer Management** - Comprehensive client lifecycle management 2. **Opportunity Management** - Sales pipeline and revenue forecasting 3. **Contract Management** - AI-powered contract lifecycle with milestone tracking 4. **Financial Management** - Order-level receivables and payments management 5. **AppBase** - Foundation module for code and parameter management 6. **RBAC** - Role-based access control and multi-tenant security The application follows all established module development specifications and provides a cohesive user experience through a tab-based navigation interface. ## Core Features ### Unified Interface - **TabPanel Navigation**: Single-page application with six main tabs - **Responsive Design**: Adapts to different screen sizes and devices - **Consistent UX**: Uniform styling and interaction patterns across all modules - **Integrated Login**: Centralized authentication using RBAC module ### Module Integration Points #### Customer ↔ Opportunity Integration - Customer 360° view includes associated opportunities - Opportunity creation can reference existing customers - Handover workflows include both customer and opportunity data #### Opportunity ↔ Contract Integration - One-click contract generation from opportunities - Contract status automatically updates opportunity stage - Revenue forecasting considers both open opportunities and active contracts #### Contract ↔ Financial Integration - Automatic receivable creation from contract payment milestones - Order-level financial tracking linked to contract fulfillment - Payment completion triggers contract milestone updates #### Financial ↔ Customer Integration - Customer financial summary shows total receivables/payments - Overdue notifications sent to both sales and finance teams - Customer credit limits enforced during opportunity/contract creation ### Security and Multi-tenancy - **Organization Isolation**: All data separated by org_id - **RBAC Permissions**: Fine-grained access control per module and function - **Audit Trail**: Comprehensive logging of all critical operations - **API Key Management**: Programmatic access via userapp table ## Technical Architecture ### Frontend Architecture - **Bricks Framework**: JSON-driven component system - **Main Layout**: `base.ui` with TabPanel organizing all modules - **Authentication**: `login.ui` + `login.dspy` using RBAC functions - **Module Integration**: Frame components loading individual module UIs ### Backend Architecture - **Module Loader**: `init.py` loads all six modules in correct order - **Dependency Order**: AppBase → RBAC → Business Modules - **Function Exposure**: ServerEnv exposes all required functions - **Async Design**: Proper awaitify usage for synchronous functions ### Database Architecture - **Shared Schema**: All modules use same database with org_id isolation - **Referential Integrity**: Foreign keys maintain data consistency - **Performance Optimization**: Strategic indexing on frequently queried fields - **DDL Generation**: Automated schema creation from JSON/XLSX definitions ## Directory Structure ``` integrated_crm_app/ ├── integrated_crm_app/ # Python package │ ├── __init__.py # Package marker │ └── init.py # Main module loader ├── wwwroot/ # Main application frontend │ ├── base.ui # Unified layout with TabPanel │ ├── login.ui # Centralized login form │ └── login.dspy # RBAC-integrated auth handler ├── build.sh # Build script for all modules ├── pyproject.toml # Package configuration └── README.md # Comprehensive documentation ``` ## Implementation Workflow ### Step 1: Module Preparation - Ensure all six modules exist in `~/repos/` directory - Verify each module follows development specifications - Confirm database table definitions are complete ### Step 2: Main Application Setup - Create main application directory structure - Implement unified `init.py` module loader - Design `base.ui` TabPanel layout - Create centralized authentication flow ### Step 3: Build Integration - Implement `build.sh` script to process all modules - Generate DDL scripts for database schema - Create symbolic links for frontend resources - Test module loading and function exposure ### Step 4: Testing and Validation - Verify all modules load without conflicts - Test cross-module data integration - Validate RBAC permissions across all functions - Confirm responsive design on different devices ## Usage Instructions ### Installation 1. Place all six modules in `~/repos/` directory 2. Run `./build.sh` to generate database schemas and links 3. Execute DDL scripts to create database tables 4. Start AhServer with the integrated application ### Navigation - **Login**: Access `/main/login.ui` for authentication - **Main Interface**: Redirects to `/main/base.ui` after login - **Module Switching**: Use TabPanel to navigate between modules - **System Admin**: Last tab contains RBAC and AppBase management ### Customization Points - **UI Layout**: Modify `base.ui` to rearrange or add tabs - **Authentication**: Extend `login.dspy` for additional auth methods - **Business Logic**: Add cross-module validation in individual modules - **Reporting**: Create new reports using combined data sources ## Verification Checklist - [x] All six modules load correctly in dependency order - [x] Unified TabPanel interface displays all modules - [x] Centralized authentication works with RBAC - [x] Cross-module data relationships function properly - [x] Organization-based data isolation enforced - [x] Responsive design works on mobile/desktop - [x] Build script processes all module types (JSON/XLSX) - [x] Production-ready code with proper error handling - [x] Complete documentation in README.md ## Extension Opportunities ### Advanced Features - **Workflow Automation**: Cross-module approval workflows - **Advanced Analytics**: Unified dashboards across all modules - **Mobile App**: Native mobile interface using same backend - **API Gateway**: RESTful API layer for external integration ### Integration Scenarios - **ERP Integration**: Connect with external accounting systems - **Marketing Automation**: Link with email/campaign platforms - **Document Management**: Integrate with file storage services - **Payment Gateways**: Connect with online payment processors This integrated CRM application provides a solid foundation for enterprise customer relationship management with full extensibility and customization capabilities.