CRM Cloud Platform

CRM & Cloud Platform

CRM Cloud Platform cover image

Problem & Solution

The Challenge: Businesses with multiple purchasing sites faced a critical challenge: they had no centralized way to track purchasing data in real-time. Without visibility into product purchases, weights, and average costs across branches, decision-makers lacked the insights needed to optimize procurement strategies, identify cost-saving opportunities, and respond quickly to market changes. Each branch operated in isolation, making it impossible to benchmark performance or enforce consistent purchasing policies.

The Solution: We built a hybrid cloud-local CRM platform that provides real-time visibility into purchasing transactions across all branches. The system captures purchasing data (products, weights, costs) from local systems, synchronizes it to a centralized cloud server, and presents it through an intuitive dashboard. By combining cloud-based analytics with local-first resilience, the platform enables branch managers to make data-driven decisions instantly while maintaining operational continuity even during internet outages. The hybrid architecture ensures that local systems can continue processing transactions offline, with automatic synchronization when connectivity is restored.

Key Features & Business Impact

  • Real-time purchasing data aggregation from multiple branch locations
  • Average cost calculations and trend analysis for each product and branch
  • Role-based access control (RBAC) with OAuth integration for secure, multi-level permissions
  • Hybrid cloud-local architecture enabling offline-first operations and zero data loss
  • Automatic data synchronization between local systems and centralized cloud server
  • Intuitive dashboard for branch managers to monitor purchasing metrics and make faster decisions
  • Support for forecasting and inventory planning based on historical purchasing patterns
  • Multi-branch data isolation and branch-specific reporting

Technical Deep Dive

System Architecture: Hybrid Cloud-Local Model

The FPN CRM employs a sophisticated hybrid architecture that balances the benefits of centralized cloud computing with the resilience of local-first systems. The cloud server hosts the primary CRM database, business logic, and analytics engine, while local systems maintain a synchronized copy of critical data and can execute transactions independently. When a local system loses internet connectivity, it continues processing purchasing transactions locally. Upon reconnection, a robust synchronization mechanism reconciles any divergences, ensuring data consistency across the entire network. This design eliminates the single point of failure inherent in purely cloud-based systems while maintaining the scalability and centralized insights of cloud infrastructure.

Authentication & Authorization (OAuth + RBAC)

Authentication is handled through OAuth, allowing users to securely log in using established identity providers. Once authenticated, the system enforces role-based access control (RBAC) at multiple layers. At the API level, middleware validates user roles and permissions before processing requests. At the UI level, components conditionally render based on user permissions, providing a tailored experience for different user types (e.g., branch managers, regional supervisors, administrators). Roles are stored in the database and can be dynamically updated, allowing administrators to grant or revoke permissions without code changes. This separation of concerns ensures that authorization logic is centralized, auditable, and maintainable.

Real-Time Data Pipeline & Consistency

The real-time data pipeline is the heart of the system. Local systems capture purchasing transactions (product ID, quantity, weight, cost) and queue them for synchronization. The cloud server exposes REST APIs that local systems call to transmit transaction batches. Each transaction is validated, deduplicated, and inserted into the PostgreSQL database with proper indexing for fast queries. A background job aggregates this raw transaction data into branch-level summaries (total purchases, average costs, trends) and caches the results in Redis for sub-second dashboard response times. The pipeline is designed to handle high-volume transaction data (thousands of transactions per day across multiple branches) without performance degradation. Event-driven architecture ensures that updates propagate to connected dashboard clients in near real-time via WebSocket connections.

Database & Performance Optimization

The database schema is optimized for multi-branch operations and analytical queries. Transactions are stored in a normalized schema with foreign keys linking to branches, products, and users. Strategic indexes on (branch_id, created_at) and (product_id, branch_id) enable fast queries for branch-specific and product-specific analytics. To prevent slow aggregation queries, pre-computed materialized views store daily summaries by branch and product, updated incrementally as new transactions arrive. For frequently accessed metrics (e.g., average cost for a product in a branch), Redis caching reduces database load and improves response times. Connection pooling via PgBouncer ensures that the application can handle concurrent requests from multiple local systems and dashboard users without exhausting database connections. Query optimization and monitoring tools identify and eliminate slow queries before they impact users.

Technology Stack

NextJSNextJS
TypescriptTypescript
TailwindCSSTailwindCSS
PostgreSQLPostgreSQL
Drizzle ORMDrizzle ORM
PM2PM2

Designed and developed by Chaikrit Techaploog

© All rights reserved.