How trrajputdev/shopcrm works
Project Type and Purpose
• This is a full-stack retail CRM system (“ShopCRM”) with a modern React/TypeScript frontend (built with Vite and Tailwind CSS) and a PHP/Apache backend (served via XAMPP) connecting to a MySQL database.
• The frontend provides customer management UIs (list, details, add/edit forms), landing/marketing pages, and reusable UI components. The backend exposes CRUD operations through a single PHP “shop-api.php” endpoint.
High-Level Components
a. Frontend (React + Vite + TypeScript + Tailwind)
• Pages: CustomerManagement, Landing, Blog, Documentation, etc.
• Layout Components: MainLayout (Header + Sidebar), Dialogs, Loading/Error UI.
• Domain Components: CustomerList, CustomerDetails, AddCustomerForm, ShopCalculators.
• Shared UI Library: button, input, table, dialog, tabs, etc.
• Hooks & Utilities: useCustomerAPI (CRUD + error handling), lib/utils.ts, formatters, custom hooks.
b. Backend (PHP API on Apache/XAMPP)
• shop-api.php (single entry point, query-param driven actions: get_customers, create_customer, update_customer, delete_customer)
• Error handling and JSON responses.
c. Database (MySQL on XAMPP)
• customers table (id, name, email, phone, balance, timestamps)
Relationships & Data Flow
• Browser (React app) ⇄ HTTP/HTTPS ⇄ Apache/PHP API
• GET /shop-api.php?action=get_customers → returns JSON array
• POST /shop-api.php?action=create_customer, update_customer, delete_customer
• PHP API ⇄ (SQL) ⇄ MySQL
• CRUD operations on the customers table
• React’s useCustomerAPI hook centralizes all HTTP calls, state (customers, loading, error), and error handling.
Architectural Patterns & Design Principles
• Layered architecture: Presentation (Components & Pages) → API layer (custom hook) → Service layer (PHP backend) → Persistence (MySQL).
• Component-based design: each UI piece has single responsibility and is reusable.
• Hooks for cross-cutting concerns: state + side-effects (data fetching, error handling) encapsulated in useCustomerAPI.
• TypeScript for static typing: interfaces (Customer, NewCustomer) ensure consistency.
• Centralized styling & theming via Tailwind and shared UI library.