From 14d254b2d1d78144cd89a384a32419f1090a5ce0 Mon Sep 17 00:00:00 2001 From: sysadmin Date: Tue, 18 Nov 2025 22:15:53 +0000 Subject: [PATCH] refactor:Disable-sample-data-seeding-and-rename-database-to-teleshop --- CLAUDE.md | 491 ++++-------------------- LittleShop/Program.cs | 47 +-- LittleShop/appsettings.Development.json | 2 +- LittleShop/appsettings.Hostinger.json | 2 +- LittleShop/appsettings.Production.json | 2 +- LittleShop/appsettings.json | 2 +- docker-compose.yml | 2 +- nul | 0 8 files changed, 87 insertions(+), 461 deletions(-) delete mode 100644 nul diff --git a/CLAUDE.md b/CLAUDE.md index a0960a0..6be0ded 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,357 +1,78 @@ -# LittleShop Development Progress +# LittleShop - E-Commerce Platform -> ๐Ÿ“‹ **See [ROADMAP.md](./ROADMAP.md) for development priorities and security fixes** -> ๐Ÿ“Œ **See [WORKING_BASELINE_2024-09-24.md](./WORKING_BASELINE_2024-09-24.md) for current working configuration** -> โš ๏ธ **See [Deployment Best Practices](#deployment-best-practices) below for critical deployment requirements** +## Overview -## Project Status: โœ… FULLY OPERATIONAL - OCTOBER 4, 2025 +LittleShop is an ASP.NET Core 9.0 e-commerce platform with integrated Telegram bot support and cryptocurrency payment processing. -### ๐Ÿ”ง **CRITICAL INCIDENT RESOLVED (October 4, 2025)** +## Architecture -**Production Outage & Recovery:** -- **Incident**: Database schema mismatch caused complete system failure -- **Root Cause**: Code deployed without applying database migrations -- **Impact**: 502 errors, TeleBot offline, Product catalog unavailable -- **Resolution**: Database restored from backup, migrations applied, networking fixed -- **Prevention**: Enhanced CI/CD pipeline with automatic migration support - -**Key Lessons Learned:** -1. โŒ **NEVER deploy code changes without corresponding database migrations** -2. โœ… **CI/CD now automatically applies migrations** from `LittleShop/Migrations/*.sql` -3. โœ… **Always verify container networking** (docker-compose prefixes network names) -4. โœ… **Maintain regular database backups** (saved production data) - -### ๐Ÿš€ **CURRENT PRODUCTION STATUS** - -**All Systems Operational:** -- โœ… **LittleShop API**: Running at `http://littleshop:5000` (internal) / `http://localhost:5100` (host) -- โœ… **TeleBot**: Connected via `littleshop_littleshop-network`, authenticated with API -- โœ… **Nginx Proxy Manager**: Proxying `https://admin.dark.side` โ†’ `littleshop:5000` -- โœ… **Database**: SQLite with variant pricing migrations applied (508KB) -- โœ… **Networks**: Proper isolation with `littleshop_littleshop-network` and `silverpay_silverpay-network` - -**Production Configuration:** -- **Server**: srv1002428.hstgr.cloud (31.97.57.205) -- **Container Names**: `littleshop`, `telebot-service`, `nginx-proxy-manager` -- **Docker Networks**: `littleshop_littleshop-network`, `silverpay_silverpay-network` -- **Volume**: `littleshop_littleshop_data` (note the docker-compose prefix!) -- **Database**: `/app/data/littleshop-production.db` inside container - -## Deployment Best Practices - -### **Pre-Deployment Checklist** -1. โœ… Verify all database migrations are in `LittleShop/Migrations/` and committed -2. โœ… Test migrations locally before deploying to production -3. โœ… Ensure docker-compose.yml matches production configuration -4. โœ… Verify TeleBot API URL points to `http://littleshop:5000` (NOT `littleshop-admin:8080`) -5. โœ… Check network names include docker-compose prefix (e.g., `littleshop_littleshop-network`) - -### **CI/CD Pipeline Workflow** -The `.gitlab-ci.yml` pipeline automatically: -1. Builds Docker images with `--no-cache` -2. Copies images to production VPS via SSH -3. Stops running containers -4. **Applies database migrations** (with automatic backup) -5. Starts LittleShop with `docker-compose up -d` -6. Starts TeleBot with correct API URL and network connections -7. Runs health checks on product catalog API - -### **Manual Deployment Commands** (Emergency Use Only) -```bash -# Connect to production server -ssh -i ~/.ssh/littleshop_deploy_key -p 2255 sysadmin@srv1002428.hstgr.cloud - -# Stop services -cd /opt/littleshop -docker stop telebot-service littleshop -docker rm telebot-service - -# Apply migration manually -docker run --rm -v littleshop_littleshop_data:/data -v $(pwd)/LittleShop/Migrations:/migrations alpine sh -c ' - apk add sqlite - sqlite3 /data/littleshop-production.db < /migrations/YourMigration.sql -' - -# Start services -docker-compose up -d -docker run -d --name telebot-service --network silverpay_silverpay-network \ - -e LittleShop__ApiUrl=http://littleshop:5000 localhost:5000/telebot:latest -docker network connect littleshop_littleshop-network telebot-service -``` - -### **Database Migration Format** -Place migration files in `LittleShop/Migrations/` with `.sql` extension: -```sql --- Migration: Description of changes --- Date: YYYY-MM-DD - -ALTER TABLE TableName ADD COLUMN NewColumn DataType; -CREATE INDEX IF NOT EXISTS IndexName ON TableName (ColumnName); -``` - -### **Network Architecture** -``` -nginx-proxy-manager โ”€โ”€โ” - โ”‚ - โ”œโ”€โ”€โ”€ littleshop_littleshop-network โ”€โ”€โ”€ littleshop:5000 - โ”‚ โ””โ”€โ”€ telebot-service - โ”‚ -telebot-service โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€ silverpay_silverpay-network โ”€โ”€โ”€ tor-gateway -``` - -## Project Status: โœ… FULLY OPERATIONAL BASELINE - SEPTEMBER 24, 2024 - -### ๐ŸŽฏ **WORKING BASELINE ESTABLISHED (September 24, 2024, 20:15 UTC)** - -**All systems operational and integrated:** -- โœ… **TeleBot**: Fixed checkout flow (single address message), no duplicate commands -- โœ… **LittleShop Admin**: CSRF tokens fixed, Pending Payment tab added, rebranded to TeleShop -- โœ… **SilverPay**: Payment creation fixed (fiat_amount field), currency conversion working -- โœ… **Integration**: All containers on same network, DNS resolution working -- โœ… **Payments**: GBP โ†’ Crypto conversion with live rates (ยฃ10 = 0.00011846 BTC @ ยฃ84,415/BTC) - -### ๐Ÿš€ **FULL SYSTEM DEPLOYMENT (September 20, 2025)** โœ… - -#### **Production Deployment Complete** -- **LittleShop API**: Running on srv1002428.hstgr.cloud:8080 -- **SilverPAY Gateway**: Running on 31.97.57.205:8001 -- **Database**: PostgreSQL and Redis operational -- **E2E Testing**: Core functionality verified -- **Git Status**: All changes committed and pushed (commit: 13aa20f) - -#### **E2E Test Results** -- โœ… Health checks passing -- โœ… Product catalog operational (10 products, 3 categories) -- โœ… Order creation with validation working -- โœ… SilverPAY integration connected -- โš ๏ธ JWT authentication needs configuration -- โš ๏ธ Payment endpoint requires API key setup - -#### **Configuration Required** -1. **JWT Secret**: Set environment variable on server -2. **SilverPAY API Key**: Configure in appsettings.Production.json -3. **Systemd Services**: Create for automatic startup -4. **Nginx**: Configure SSL and reverse proxy -5. **Logging**: Set up rotation and monitoring - -#### **Access Points** -- **API**: http://srv1002428.hstgr.cloud:8080 -- **Admin Panel**: http://srv1002428.hstgr.cloud:8080/Admin -- **API Docs**: http://srv1002428.hstgr.cloud:8080/swagger -- **SilverPAY**: http://31.97.57.205:8001 - -## Previous Updates: โœ… BTCPAY SERVER MULTI-CRYPTO CONFIGURED - SEPTEMBER 12, 2025 - -### ๐Ÿš€ **BTCPAY SERVER INTEGRATION FIXED (September 19, 2025)** โœ… - -#### **Production Deployment Successful** -- **Fixed**: Invoice creation now uses GBP (fiat) instead of cryptocurrency -- **Fixed**: Proper checkout link generation for customer payments -- **Fixed**: Enhanced error logging and debugging -- **API Credentials**: Updated and working -- **Connection Status**: โœ… Connected to BTCPay v2.2.1 -- **Store Configuration**: CvdvHoncGLM7TdMYRAG6Z15YuxQfxeMWRYwi9gvPhh5R - -### ๐Ÿš€ **BTCPAY SERVER DEPLOYMENT (September 11-12, 2025)** โœ… - -#### **Multi-Cryptocurrency BTCPay Server Configured** โœ… -- **Host**: Hostinger VPS (srv1002428.hstgr.cloud, thebankofdebbie.giize.com) -- **Cryptocurrencies**: Bitcoin (BTC), Dogecoin (DOGE), Monero (XMR), Ethereum (ETH), Zcash (ZEC) -- **Network**: Tor integration with onion addresses for privacy -- **Storage**: Pruned mode configured (Bitcoin: 10GB max, Others: 3GB max) -- **Access**: Both clearnet HTTPS and Tor onion service available - -#### **Critical Technical Breakthrough - Bitcoin Pruning Fix** โœ… -- **Problem**: BTCPay Docker Compose YAML parsing broken - `BITCOIN_EXTRA_ARGS` not passed to container -- **Root Cause**: BTCPay's docker-compose generator creates corrupted multiline YAML that Docker can't parse -- **Multiple Failed Attempts**: - - โŒ Manual bitcoin.conf editing (overwritten by entrypoint script) - - โŒ docker-compose.yml direct editing (YAML formatting issues) - - โŒ .env file approach (not inherited properly) - - โŒ YAML format variations (`|-`, `|`, `>` - all failed) -- **SOLUTION**: `docker-compose.override.yml` with clean YAML formatting -- **Success Evidence**: `Prune configured to target 10000 MiB on disk for block and undo files.` - -#### **BTCPay Configuration Details** -- **Bitcoin Core**: Pruned (10GB max), Tor-only networking (`onlynet=onion`) -- **Dogecoin**: Configured but needs pruning configuration applied -- **Monero**: Daemon operational, wallet configuration in progress -- **Ethereum**: Configured in BTCPay but container needs investigation -- **Zcash**: Wallet container present, main daemon needs configuration -- **Tor Integration**: Complete with hidden service generation -- **SSL**: Let's Encrypt certificates via nginx proxy - -#### **Infrastructure Lessons Learned** -- **Docker Compose Override Files**: Survive BTCPay updates, proper way to customize configuration -- **BTCPay Template System**: The generated docker-compose.yml gets overwritten on updates -- **Bitcoin Container Entrypoint**: Completely overwrites bitcoin.conf from `BITCOIN_EXTRA_ARGS` environment variable -- **YAML Parsing Issues**: BTCPay's multiline string generation is fragile and often corrupted -- **Space Management**: Cryptocurrency daemons without pruning consume massive disk space (50-80GB each) - -#### **Deployment Architecture** -- **VPS**: Hostinger Debian 13 (394GB storage, 239GB available after cleanup) -- **Docker Services**: 14 containers including Bitcoin, altcoin daemons, Tor, nginx, PostgreSQL -- **Network Security**: UFW firewall, SSH on port 2255, Fail2Ban monitoring -- **Tor Privacy**: All cryptocurrency P2P traffic routed through Tor network -- **SSL Termination**: nginx reverse proxy with Let's Encrypt certificates - -## Project Status: โœ… COMPILATION ISSUES RESOLVED - SEPTEMBER 5, 2025 - -### ๐Ÿ”ง **LATEST TECHNICAL FIXES (September 5, 2025)** โœ… - -#### **Compilation Errors Resolved** โœ… -- **CryptoCurrency Enum**: Restored all supported cryptocurrencies (XMR, USDT, ETH, ZEC, DOGE) -- **BotSimulator Fix**: Fixed string-to-int conversion error in payment creation -- **Security Update**: Updated SixLabors.ImageSharp to v3.1.8 (vulnerability fix) -- **Test Infrastructure**: Installed Playwright browsers for UI testing - -#### **Build Status** โœ… -- **Main Project**: Builds successfully with zero compilation errors -- **All Projects**: TeleBot, LittleShop.Client, and test projects compile cleanly -- **Package Warnings**: Only minor version resolution warnings remain (non-breaking) - -### ๐ŸŽฏ **BOT/UI BASELINE (August 28, 2025)** โœ… - -#### **Complete TeleBot Integration** โœ… -- **Customer Orders**: Full order history and details lookup working -- **Product Browsing**: Enhanced UI with individual product bubbles -- **Admin Authentication**: Fixed role-based authentication with proper claims -- **Bot Management**: Cleaned up development data, single active bot registration -- **Navigation Flow**: Improved UX with consistent back/menu navigation -- **Message Formatting**: Clean section headers without emojis, professional layout - -#### **Technical Fixes Applied** -- **Customer Order Endpoints**: Added `/api/orders/by-customer/{customerId}/{id}` for secure customer access -- **Admin Role Claims**: Fixed missing "Admin" role claim in cookie authentication -- **AccessDenied View**: Created missing view to prevent 500 errors on unauthorized access -- **Bot Cleanup**: Removed 16 duplicate development bot registrations, kept 1 active -- **Product Bubble UI**: Individual product messages with Quick Buy/Details buttons -- **Navigation Enhancement**: Streamlined navigation with proper menu flow - -### Completed Implementation (August 20, 2025) - -#### ๐Ÿ—๏ธ **Architecture** - **Framework**: ASP.NET Core 9.0 Web API + MVC - **Database**: SQLite with Entity Framework Core - **Authentication**: Dual-mode (Cookie for Admin Panel + JWT for API) - **Structure**: Clean separation between Admin Panel (MVC) and Client API (Web API) -#### ๐Ÿ—„๏ธ **Database Schema** โœ… -- **Tables**: Users, Categories, Products, ProductPhotos, Orders, OrderItems, CryptoPayments -- **Relationships**: Proper foreign keys and indexes -- **Enums**: ProductWeightUnit, OrderStatus, CryptoCurrency, PaymentStatus -- **Default Data**: Admin user (admin/admin) auto-seeded +## Database Schema -#### ๐Ÿ” **Authentication System** โœ… -- **Admin Panel**: Cookie-based authentication for staff users -- **Client API**: JWT authentication ready for client applications -- **Security**: PBKDF2 password hashing, proper claims-based authorization -- **Users**: Staff-only user management (no customer accounts stored) +**Core Tables:** +- Users (Staff authentication) +- Categories +- Products +- ProductPhotos +- ProductVariations (quantity-based pricing) +- Orders +- OrderItems +- CryptoPayments -#### ๐Ÿ›’ **Admin Panel (MVC)** โœ… -- **Dashboard**: Overview with statistics and quick actions -- **Categories**: Full CRUD operations working -- **Products**: Full CRUD operations working with photo upload support -- **Users**: Staff user management working -- **Orders**: Order management and status tracking -- **Views**: Bootstrap-based responsive UI with proper form binding +**Key Features:** +- Proper foreign key relationships +- Product variations (e.g., 1 for ยฃ10, 2 for ยฃ19, 3 for ยฃ25) +- Order workflow tracking with user accountability +- Soft delete support (IsActive flag) -#### ๐Ÿ”Œ **Client API (Web API)** โœ… -- **Catalog Endpoints**: - - `GET /api/catalog/categories` - Public category listing - - `GET /api/catalog/products` - Public product listing -- **Order Management**: - - `POST /api/orders` - Create orders by identity reference - - `GET /api/orders/by-identity/{id}` - Get client orders - - `POST /api/orders/{id}/payments` - Create crypto payments - - `POST /api/orders/payments/webhook` - BTCPay Server webhooks +## Features -#### ๐Ÿ’ฐ **Multi-Cryptocurrency Support** โœ… -- **Supported Currencies**: BTC, XMR (Monero), USDT, LTC, ETH, ZEC (Zcash), DASH, DOGE -- **BTCPay Server Integration**: Complete client implementation with webhook processing -- **Privacy Design**: No customer personal data stored, identity reference only -- **Payment Workflow**: Order โ†’ Payment generation โ†’ Blockchain monitoring โ†’ Status updates +### Admin Panel (MVC) +- Dashboard with statistics +- Category management (CRUD) +- Product management with photo uploads +- Product variations management +- Order workflow management +- User management (staff only) +- Mobile-responsive design -#### ๐Ÿ“ฆ **Features Implemented** -- **Product Management**: Name, description, weight/units, pricing, categories, photos -- **Order Workflow**: Creation โ†’ Payment โ†’ Processing โ†’ Shipping โ†’ Tracking -- **File Upload**: Product photo management with alt text support -- **Validation**: FluentValidation for input validation, server-side model validation -- **Logging**: Comprehensive Serilog logging to console and files -- **Documentation**: Swagger API documentation with JWT authentication +### Client API (Web API) +- Public product catalog +- Order creation and management +- Customer order lookup +- Payment processing integration +- Swagger documentation -### ๐Ÿ”ง **Technical Lessons Learned** +### Payment System +- Multi-cryptocurrency support (BTC, XMR, USDT, LTC, ETH, ZEC, DASH, DOGE) +- BTCPay Server integration +- Privacy-focused (no customer personal data stored) +- Webhook processing for payment status updates -#### **ASP.NET Core 9.0 Specifics** -1. **Model Binding Issues**: Views need explicit model instances (`new CreateDto()`) for proper binding -2. **Form Binding**: Using explicit `name` attributes more reliable than `asp-for` helpers in some cases -3. **Area Routing**: Requires proper route configuration and area attribute on controllers -4. **View Engine**: Runtime changes to views require application restart in Production mode +### TeleBot Integration +- Product browsing with individual product bubbles +- Customer order history and tracking +- Quick buy functionality +- Professional message formatting -#### **Entity Framework Core** -1. **SQLite Works Well**: Handles all complex relationships and transactions properly -2. **Query Splitting Warning**: Multi-include queries generate warnings but work correctly -3. **Migrations**: `EnsureCreated()` sufficient for development, migrations better for production -4. **Decimal Precision**: Proper `decimal(18,2)` and `decimal(18,8)` column types for currency +## Default Credentials -#### **Authentication Architecture** -1. **Dual Auth Schemes**: Successfully implemented both Cookie (MVC) and JWT (API) authentication -2. **Claims-Based Security**: Works well for role-based authorization policies -3. **Password Security**: PBKDF2 with 100,000 iterations provides good security -4. **Session Management**: Cookie authentication handles admin panel sessions properly +**Admin Account:** +- Username: `admin` +- Password: `admin` -#### **BTCPay Server Integration** -1. **Version Compatibility**: BTCPay Server Client v2.0 has different API than v1.x -2. **Package Dependencies**: NBitcoin version conflicts require careful package management -3. **Privacy Focus**: Self-hosted approach eliminates third-party data sharing -4. **Webhook Processing**: Proper async handling for payment status updates +## File Structure -#### **Development Challenges Solved** -1. **WSL Environment**: Required CMD.exe for .NET commands, file locking issues with hot reload -2. **View Compilation**: Views require app restart in Production mode to pick up changes -3. **Form Validation**: Empty validation summaries appear due to ModelState checking -4. **Static Files**: Proper configuration needed for product photo serving - -### ๐Ÿš€ **Current System Status** - -#### **โœ… Fully Working** -- Admin Panel authentication (admin/admin) with proper role claims -- Category management (Create, Read, Update, Delete) -- Product management (Create, Read, Update, Delete) -- User management for staff accounts -- Public API endpoints for client integration -- Database persistence and relationships -- Multi-cryptocurrency payment framework -- **TeleBot Integration**: Complete customer order system -- **Product Bubble UI**: Enhanced product browsing experience -- **Bot Management**: Clean single bot registration -- **Customer Orders**: Full order history and details access -- **Navigation Flow**: Improved UX with consistent menu navigation - -#### **๐Ÿ”ฎ Ready for Tomorrow** -- Order creation and payment testing via TeleBot -- Multi-crypto payment workflow end-to-end test -- Royal Mail shipping integration -- Production deployment considerations -- Advanced bot features and automation - -### ๐Ÿ“ **File Structure Created** ``` LittleShop/ โ”œโ”€โ”€ Controllers/ (Client API) -โ”‚ โ”œโ”€โ”€ CatalogController.cs -โ”‚ โ”œโ”€โ”€ OrdersController.cs -โ”‚ โ”œโ”€โ”€ HomeController.cs -โ”‚ โ””โ”€โ”€ TestController.cs -โ”œโ”€โ”€ Areas/Admin/ (Admin Panel) +โ”œโ”€โ”€ Areas/Admin/ (Admin Panel MVC) โ”‚ โ”œโ”€โ”€ Controllers/ -โ”‚ โ”‚ โ”œโ”€โ”€ AccountController.cs -โ”‚ โ”‚ โ”œโ”€โ”€ DashboardController.cs -โ”‚ โ”‚ โ”œโ”€โ”€ CategoriesController.cs -โ”‚ โ”‚ โ”œโ”€โ”€ ProductsController.cs -โ”‚ โ”‚ โ”œโ”€โ”€ OrdersController.cs -โ”‚ โ”‚ โ””โ”€โ”€ UsersController.cs -โ”‚ โ””โ”€โ”€ Views/ (Bootstrap UI) +โ”‚ โ””โ”€โ”€ Views/ โ”œโ”€โ”€ Services/ (Business Logic) โ”œโ”€โ”€ Models/ (Database Entities) โ”œโ”€โ”€ DTOs/ (Data Transfer Objects) @@ -360,99 +81,27 @@ LittleShop/ โ””โ”€โ”€ wwwroot/uploads/ (File Storage) ``` -### ๐ŸŽฏ **Performance Notes** -- **Database**: SQLite performs well for development, 106KB with sample data -- **Startup Time**: ~2 seconds with database initialization -- **Memory Usage**: Efficient with proper service scoping -- **Query Performance**: EF Core generates optimal SQLite queries +## Technical Notes -### ๐Ÿ”’ **Security Implementation** -- **No KYC Requirements**: Privacy-focused design -- **Minimal Data Collection**: Only identity reference stored for customers -- **Self-Hosted Payments**: BTCPay Server eliminates third-party payment processors -- **Encrypted Storage**: Passwords properly hashed with salt -- **CORS Configuration**: Prepared for web client integration +### ASP.NET Core 9.0 +- Views need explicit model instances for proper binding +- Area routing requires proper route configuration +- Both Cookie (Admin) and JWT (API) authentication schemes -## ๐Ÿš€ **PRODUCT VARIATIONS & MOBILE WORKFLOW - SEPTEMBER 18, 2025** ๐Ÿš€ +### Entity Framework Core +- SQLite handles complex relationships efficiently +- Database initialization via `EnsureCreated()` for development +- Proper decimal precision for currency values -**Complete product variations system with mobile-responsive order workflow implemented!** +### Security +- PBKDF2 password hashing (100,000 iterations) +- Claims-based authorization +- No customer PII storage (privacy-focused) +- CORS configuration ready -### **Key Achievements:** -- โœ… Product variations system (1 for ยฃ10, 2 for ยฃ19, 3 for ยฃ25) -- โœ… Enhanced order workflow (Accept โ†’ Packing โ†’ Dispatched โ†’ Delivered) -- โœ… Mobile-responsive interface (tables on desktop, cards on mobile) -- โœ… CSV import/export system for bulk product management -- โœ… Self-contained deployment (no external CDN dependencies) -- โœ… Enhanced dashboard with variations metrics +## Development Environment -### **Critical Technical Improvements:** - -#### **Product Variations Architecture** โœ… -- **ProductVariation Model**: Quantity-based pricing with automatic price-per-unit calculation -- **Database Schema**: Proper relationships with UNIQUE constraints on ProductId+Quantity -- **Order Integration**: OrderItems support ProductVariationId for variation pricing -- **API Support**: Full REST endpoints for variation management -- **Admin Interface**: Complete CRUD with duplicate detection and user guidance - -#### **Enhanced Order Workflow** โœ… -- **Status Flow**: PendingPayment โ†’ PaymentReceived โ†’ Accepted โ†’ Packing โ†’ Dispatched โ†’ Delivered -- **User Tracking**: AcceptedByUser, PackedByUser, DispatchedByUser for accountability -- **Timeline Tracking**: AcceptedAt, PackingStartedAt, DispatchedAt timestamps -- **Smart Delivery Calculation**: Auto-calculates delivery dates (working days, skips weekends) -- **On Hold Workflow**: Side workflow for problem resolution with reason tracking -- **Tab-Based Interface**: Workflow-focused UI with badge counts for urgent items - -#### **Mobile-First Design** โœ… -- **Responsive Breakpoints**: `d-none d-lg-block` (desktop table) / `d-lg-none` (mobile cards) -- **Touch-Friendly UI**: Large buttons, card layouts, horizontal scrolling tabs -- **Adaptive Content**: Smart text switching (`Accept Orders` vs `Accept` on mobile) -- **Visual Status**: Color-coded borders and badges for at-a-glance status recognition - -#### **Bulk Import System** โœ… -- **CSV Format**: Supports products + variations in single file -- **Variations Import**: "Single Item:1:10.00;Twin Pack:2:19.00;Triple Pack:3:25.00" format -- **Category Resolution**: Uses category names instead of GUIDs -- **Error Reporting**: Detailed import results with row-level error reporting -- **Template System**: Download ready-to-use CSV templates - -#### **Form Binding Resolution** โœ… -- **Fixed ASP.NET Core Issue**: Changed from `asp-for` to explicit `name` attributes -- **Validation Enhancement**: Proper ModelState error display with Bootstrap styling -- **Cache Busting**: Added no-cache headers to ensure updated forms load -- **Debug Logging**: Console output for troubleshooting form submissions - -### **Production Deployment Readiness** โœ… -- **Self-Contained**: All external CDN dependencies replaced with local libraries -- **Isolated Networks**: Ready for air-gapped/restricted environments -- **Mobile Optimized**: End users can efficiently manage orders on mobile devices -- **Bulk Management**: CSV import/export for efficient product catalog management - -## ๐ŸŽ‰ **SYSTEM NOW PRODUCTION-READY** ๐ŸŽ‰ - -**Complete e-commerce system with advanced features ready for mobile-first operations!** ๐ŸŒŸ - -## ๐Ÿงช **Testing Status (September 5, 2025)** - -### **Current Test Results** -- **Build Status**: โœ… All projects compile successfully -- **Unit Tests**: โš ๏ธ 24/41 passing (59% pass rate) -- **Integration Tests**: โš ๏ธ Multiple service registration issues -- **UI Tests**: โœ… Playwright browsers installed and ready - -### **Known Test Issues** -- **Push Notification Tests**: Service mocking configuration needs adjustment -- **Service Tests**: Some expect hard deletes but services use soft deletes (IsActive = false) -- **Integration Tests**: Test service registration doesn't match production services -- **Authentication Tests**: JWT vs Cookie authentication scheme mismatches - -### **Test Maintenance Recommendations** -1. **Service Registration**: Update TestWebApplicationFactory to register all required services -2. **Test Expectations**: Align test expectations with actual service behavior (soft vs hard deletes) -3. **Authentication Setup**: Standardize test authentication configuration -4. **Mock Configuration**: Review and fix service mocking in unit tests -5. **Data Seeding**: Ensure consistent test data setup across test categories - -### **Production Impact** -- โœ… **Zero Impact**: All compilation issues resolved, application runs successfully -- โœ… **Core Functionality**: All main features work as expected in production -- โš ๏ธ **Test Coverage**: Tests need maintenance but don't affect runtime operation \ No newline at end of file +- **Platform**: Windows/WSL +- **Command Shell**: cmd.exe recommended for .NET commands +- **Database**: SQLite (file-based, no server required) +- **Hot Reload**: Views require app restart in Production mode diff --git a/LittleShop/Program.cs b/LittleShop/Program.cs index 930415d..f99df6d 100644 --- a/LittleShop/Program.cs +++ b/LittleShop/Program.cs @@ -431,52 +431,29 @@ app.MapGet("/api/version", () => }); }); -// Apply database migrations and seed data +// Apply database migrations using (var scope = app.Services.CreateScope()) { var context = scope.ServiceProvider.GetRequiredService(); - // Use proper migrations in production, EnsureCreated only for development/testing - if (app.Environment.IsProduction()) + // Always use migrations for consistent database initialization + Log.Information("Applying database migrations..."); + try { - Log.Information("Production environment: Applying database migrations..."); - try - { - context.Database.Migrate(); - Log.Information("Database migrations applied successfully"); - } - catch (Exception ex) - { - Log.Fatal(ex, "Database migration failed. Application cannot start."); - throw; - } + context.Database.Migrate(); + Log.Information("Database migrations applied successfully"); } - else + catch (Exception ex) { - Log.Information("Development/Testing environment: Using EnsureCreated"); - context.Database.EnsureCreated(); + Log.Fatal(ex, "Database migration failed. Application cannot start."); + throw; } - - // Seed default admin user + + // Seed default admin user only var authService = scope.ServiceProvider.GetRequiredService(); await authService.SeedDefaultUserAsync(); - // Seed sample data - only in development - if (app.Environment.IsDevelopment()) - { - Log.Information("Development environment: Seeding sample data"); - var dataSeeder = scope.ServiceProvider.GetRequiredService(); - await dataSeeder.SeedSampleDataAsync(); - } - - // Seed system settings - enable test currencies only in development - if (app.Environment.IsDevelopment()) - { - Log.Information("Development environment: Enabling test currencies"); - var systemSettings = scope.ServiceProvider.GetRequiredService(); - await systemSettings.SetTestCurrencyEnabledAsync("TBTC", true); - await systemSettings.SetTestCurrencyEnabledAsync("TLTC", true); - } + Log.Information("Database initialization complete - fresh install ready"); } Log.Information("LittleShop API starting up..."); diff --git a/LittleShop/appsettings.Development.json b/LittleShop/appsettings.Development.json index 5db3fc2..d8b57b6 100644 --- a/LittleShop/appsettings.Development.json +++ b/LittleShop/appsettings.Development.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "DefaultConnection": "Data Source=littleshop-dev.db" + "DefaultConnection": "Data Source=teleshop-dev.db" }, "Jwt": { "Key": "DEVELOPMENT_USE_DOTNET_USER_SECRETS_OR_ENV_VAR", diff --git a/LittleShop/appsettings.Hostinger.json b/LittleShop/appsettings.Hostinger.json index 394ff6a..eebe5c6 100644 --- a/LittleShop/appsettings.Hostinger.json +++ b/LittleShop/appsettings.Hostinger.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "DefaultConnection": "Data Source=/app/data/littleshop.db" + "DefaultConnection": "Data Source=/app/data/teleshop.db" }, "Jwt": { "Key": "YourSuperSecretKeyThatIsAtLeast32CharactersLong!", diff --git a/LittleShop/appsettings.Production.json b/LittleShop/appsettings.Production.json index d358ce9..c41fb6a 100644 --- a/LittleShop/appsettings.Production.json +++ b/LittleShop/appsettings.Production.json @@ -7,7 +7,7 @@ } }, "ConnectionStrings": { - "DefaultConnection": "Data Source=littleshop-production.db" + "DefaultConnection": "Data Source=teleshop-production.db" }, "Jwt": { "Key": "${JWT_SECRET_KEY}", diff --git a/LittleShop/appsettings.json b/LittleShop/appsettings.json index edca660..cb026e4 100644 --- a/LittleShop/appsettings.json +++ b/LittleShop/appsettings.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "DefaultConnection": "Data Source=littleshop.db" + "DefaultConnection": "Data Source=teleshop.db" }, "Jwt": { "Key": "", diff --git a/docker-compose.yml b/docker-compose.yml index 1e9f6a0..07c0f82 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,7 +11,7 @@ services: environment: - ASPNETCORE_ENVIRONMENT=Production - ASPNETCORE_URLS=http://+:5000 - - ConnectionStrings__DefaultConnection=Data Source=/app/data/littleshop-prod.db + - ConnectionStrings__DefaultConnection=Data Source=/app/data/teleshop-prod.db - Jwt__Key=LittleShop-Production-JWT-SecretKey-32Characters-2025 - Jwt__Issuer=LittleShop - Jwt__Audience=LittleShop diff --git a/nul b/nul deleted file mode 100644 index e69de29..0000000