crmbackend/context.txt

49 lines
2.9 KiB
Text
Raw Normal View History

seller central backend : /home/vignesh/github/seller_central_backend
customer site backend : /home/vignesh/github/customerwebsitebackend
=========================================
PROJECTS ARCHITECTURE & SYSTEM KNOWLEDGE
=========================================
1. PROJECT REPOSITORIES
-----------------------
* CRM Backend: /home/vignesh/github/crmbackend (Django)
* CRM Frontend: /home/vignesh/github/crmfrontend (React SPA)
* Seller Central Backend: /home/vignesh/github/seller_central_backend (Django)
* Customer Website Backend: /home/vignesh/github/customerwebsitebackend (Django)
2. DATABASE ARCHITECTURE (PostgreSQL on EC2)
---------------------------------------------
The system is divided into five distinct PostgreSQL databases on the server:
* `crmmanagement`: Contains Django auth, admin logs, and CRM central AuditLogs (`crm_auditlog`).
* `sellerprofile`: Contains seller profiles (`api_supplierprofile`) and credentials (`auth_user`).
* `productprofile`: Contains approved product listings (`api_product`) and submissions (`product_submissions`).
* `customerprofile`: Contains user wallets (`api_wallet` & `api_wallettransaction`).
* `customerwebsite`: Contains customer registrations (`orders_customerprofile`), orders (`orders_order`), and credentials (`auth_user`).
3. CRM DATABASE ROUTING (`db_router.py`)
----------------------------------------
In `crmbackend/digihoxbackend/db_router.py`, models are mapped as follows:
* `default` -> default database (`crmmanagement`)
* `seller_models.SupplierProfile` -> `seller_db` (`sellerprofile` database)
* `seller_models.Product` -> `product_db` (`productprofile` database)
* `seller_models.Wallet`/`WalletTransaction` -> `customer_db` (`customerwebsite` database)
* `customer_models.CustomerProfile`/`Order` -> `customer_db` (`customerwebsite` database)
4. IMPORTANT MODEL MAPPINGS (Unmanaged Proxy Models)
------------------------------------------------------
To align with the production databases, CRM models are mapped to the actual tables:
* `SupplierProfile` (unmanaged) -> `api_supplierprofile`
- Name and Email are mapped to properties fetching dynamically from `auth_user` table in `seller_db`.
* `Product` (unmanaged) -> `api_product` (with column `title` mapped to property `name`).
- Status/is_active write operations are bypassed during saves since table lacks status columns.
* `CustomerProfile` (unmanaged) -> `orders_customerprofile`
- Name and Email fetched dynamically from `auth_user` in `customer_db`.
- Customer status property is mapped to the `is_active` flag in customer website database credentials.
* `Order` (unmanaged) -> `orders_order`.
5. CUSTOMER ACTION ACTIONS
--------------------------
* Banning/suspending customers executes `UPDATE auth_user SET is_active = False` in the `customer_db` database to disable customer site logins. Reinstating sets `is_active = True`.
* Removing a seller deletes the profile from `api_supplierprofile` and deletes the login user record from `auth_user` inside `seller_db`.