- Backend: FastAPI app with all models, services, schemas, routes - Admin Panel: Next.js dashboard with all modules (CRM, POS, repairs, warranties, billing, notifications, etc.) - Ecommerce: storefront (submodule) + product catalog - AI Agents: .agents/ skill library for Antigravity IDE - Docs: architecture, billing, notification gateway markdown - Submodules: Backend/OpenWA, Ecommerce/File 2/storefront
37 lines
1.1 KiB
Markdown
37 lines
1.1 KiB
Markdown
# Database Indexing Strategy
|
|
|
|
To maintain sub-50ms query performance across 50M+ rows:
|
|
|
|
---
|
|
|
|
## Target Composite Indexes
|
|
|
|
### 1. `products` Table
|
|
```sql
|
|
CREATE INDEX idx_products_category_brand ON products(category_id, brand_id, status);
|
|
CREATE INDEX idx_products_slug ON products(slug);
|
|
```
|
|
|
|
### 2. `product_variants` Table
|
|
```sql
|
|
CREATE UNIQUE INDEX idx_variants_sku ON product_variants(sku);
|
|
CREATE UNIQUE INDEX idx_variants_barcode ON product_variants(barcode);
|
|
CREATE INDEX idx_variants_product_price ON product_variants(product_id, price);
|
|
```
|
|
|
|
### 3. `orders` Table
|
|
```sql
|
|
CREATE INDEX idx_orders_customer_date ON orders(customer_id, created_at DESC);
|
|
CREATE INDEX idx_orders_status_date ON orders(status, created_at DESC);
|
|
```
|
|
|
|
### 4. `inventory_ledger` Table
|
|
```sql
|
|
CREATE INDEX idx_ledger_variant_event ON inventory_ledger(variant_id, event_type, created_at);
|
|
```
|
|
|
|
### 5. `outbox_events` Table
|
|
```sql
|
|
CREATE INDEX idx_outbox_status_created ON outbox_events(status, created_at);
|
|
CREATE INDEX idx_outbox_aggregate ON outbox_events(aggregate_type, aggregate_id, aggregate_version);
|
|
```
|