# Current State Architecture & System Assessment ## Existing Stack Audit ### 1. Frontend * **Storefront E-Commerce**: Next.js App Router (`Ecommerce Page`, Port 3021) utilizing React Server Components (RSC) and parallelized data fetches. * **Admin ERP/CRM Portal**: Next.js App Router (`Admin Ecommerce`, Port 3022) with dynamic storefront management components. ### 2. Backend * **Framework**: FastAPI (Python 3.11+). * **Database Driver**: PyMySQL + SQLAlchemy 2.0 ORM. * **Security & Auth**: Admin JWT bearer auth (`User`, `Role`, `Permission`). Customer Auth pending. ### 3. Database * **Engine**: MySQL 8.0+ / MariaDB. * **Identifier Standard**: 26-character String IDs (ULID format). * **Existing Models**: `User`, `Role`, `Permission`, `Product`, `ProductVariant`, `VariantAttribute`, `Category`, `Brand`, `DeviceCatalog`, `StockMovement`, `StorefrontContent`, `AuditLog`. --- ## Gap Analysis (Existing vs Enterprise Target) | Domain | Current Codebase Implementation | Gaps / Missing Capabilities | | :--- | :--- | :--- | | **Customer Auth** | Employee/User Auth present in `UserModel.py` | Missing `EcomCustomer` model, Google OAuth 2.0 flow, Customer JWT sessions | | **E-Commerce Flow** | Mock responses in `StorefrontRouter.py` | Missing `Order`, `OrderItem`, `Cart`, `Checkout`, and `Razorpay` payment state machine | | **Invoicing** | Not implemented | Missing online/offline GST-compliant invoice series engine | | **Offline POS** | Not implemented | Missing Tauri + SQLite offline desktop application & sync gateway | | **Search Engine** | Basic SQL filter queries | Missing OpenSearch projection layer & Outbox event relay | | **Inventory** | Basic stock movement logs | Missing append-only Inventory Ledger with stock bucket calculation |