cmd/web/main.go serves as the application entry point, wiring together
configuration, database, templates, and route handlers. All business logic lives in internal/
following Go's enforced package visibility rules — preventing external imports and maintaining strict boundaries.
| Component | Technology | Purpose & Details |
|---|---|---|
| Language | Go 1.23+ | Compiled language with goroutines, garbage collection, and a powerful standard library. Zero external framework dependency. |
| Database | MySQL 8.x | Relational database via XAMPP. ACID-compliant transactions, robust indexing, and proven reliability for e-commerce workloads. |
| DB Driver | sqlx + go-sql-driver | jmoiron/sqlx extends stdlib database/sql with struct scanning and named queries. Connection pool: 25 open / 5 idle. |
| Templates | html/template | Go stdlib template engine with auto-escaping for XSS protection. Compiled at startup for fast rendering. |
| Frontend | HTMX + Vanilla CSS | Hypermedia-driven updates without JavaScript frameworks. Zero build step, minimal payload, instant page interactions. |
| Auth | Argon2id | Memory-hard password hashing (OWASP recommended). Resistant to GPU/ASIC brute-force attacks. |
| Payment | Razorpay | HMAC-SHA256 signature verification, webhook support, and server-side payment confirmation. |
| SMTP + Queue Worker | Async email delivery via background goroutine. Retry logic (3 attempts), TLS/SSL support, queue-based processing. | |
| Config | godotenv | 12-factor app configuration via .env files. No hardcoded secrets, environment-aware deployment. |
| Security | CSRF + Sessions | Double-submit cookie pattern for CSRF. HttpOnly, SameSite=Lax cookies. Session expiry (7 days admin). |
Compiled to Native Binary
Go compiles directly to machine code — no interpreter overhead, no VM warm-up. The avrfashionwear.exe binary starts instantly and uses minimal memory (~15MB RSS) compared to Node.js (~80MB) or Python (~45MB).
Goroutines — Lightweight Concurrency
Each HTTP request is handled by a goroutine (~2KB stack) instead of an OS thread (~1MB). Go can handle 10,000+ concurrent connections on modest hardware. The email queue worker runs as a background goroutine with zero threading complexity.
Standard Library Powerhouse
net/http, html/template, crypto/hmac, database/sql — Go's stdlib covers everything AVR needs. No framework lock-in, no dependency hell. The entire go.sum has only 5 dependencies.
Static Typing & Safety
Compile-time type checking catches bugs before deployment. Struct tags (db:"column") enable automatic database mapping. No runtime type errors in production.
Connection Pooling Built-In
sql.DB manages a pool of 25 connections with automatic lifecycle management. SetConnMaxLifetime(5min) prevents stale connections. No external connection pooler needed.
Cross-Platform Deployment
GOOS=linux GOARCH=amd64 go build produces a single static binary. Deploy to any server, Docker container, or cloud function with zero runtime dependencies.
Built-in Race Detector
go run -race detects data races at development time. Critical for concurrent cart operations, session management, and database writes in an e-commerce context.
Package-Level Encapsulation
The internal/ directory convention prevents external packages from importing private code. Models, handlers, and middleware are truly encapsulated — not just by convention, but by compiler enforcement.
func main() { cfg := config.Load() database := db.Connect(cfg) defer database.Close() tmpl := loadTemplates() h := handlers.NewHandlers(database, tmpl) // Start email queue worker (goroutine) email.StartQueueWorker(database) // Static file server http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) // 60+ route registrations... http.HandleFunc("/", h.Home) http.HandleFunc("/shop", h.ProductList) http.HandleFunc("/cart", h.CartView) // ... // CSRF validation wrapper handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if r.Method == "POST" && !middleware.ValidateCSRF(r) { http.Error(w, "CSRF token mismatch", http.StatusForbidden) return } http.DefaultServeMux.ServeHTTP(w, r) }) log.Fatal(http.ListenAndServe(addr, handler)) }
- ✗Plugin-heavy architecture with dependency conflicts
- ✗PHP interpreter overhead on every request (~50ms)
- ✗Licensed theme lock-in, limited customization
- ✗Monthly fees and transaction percentage cuts
- ✗Database bloat from plugin metadata
- ✗Shared hosting resource contention
- ✓Single binary — zero runtime dependencies
- ✓Compiled native code (~2ms response time)
- ✓Full source ownership, unlimited customization
- ✓Zero licensing fees, zero transaction cuts
- ✓Clean schema with 17 focused migration files
- ✓Dedicated server, predictable performance
- ✗Single-threaded event loop bottleneck on CPU tasks
- ✗npm dependency tree (500+ packages typical)
- ✗JSON serialization overhead for SSR
- ✗Callback/promise complexity for database operations
- ✗Higher memory footprint per connection
- ✓True parallelism via goroutines on all CPU cores
- ✓Only 5 direct dependencies in go.mod
- ✓Native HTML template compilation at startup
- ✓Sync, readable code with error handling
- ✓~15MB memory footprint under load
Relative Performance Comparison (Requests/sec)
Core E-Commerce Tables
| Table | Key Columns | Purpose |
|---|---|---|
| products | id, name, slug, price, sale_price, sku, stock, image, featured, status | Product catalog with pricing and inventory |
| categories | id, name, slug, description, image | Product categorization (Men, Women, Kids) |
| product_variations | id, product_id, size, color, color_hex, sku, price, stock | Size/color variants per product |
| product_images | id, product_id, image, sort_order | Gallery images with ordering |
Order & User Tables
| Table | Key Columns | Purpose |
|---|---|---|
| orders | id, user_id, total, status, payment_method, payment_id, payment_status | Order tracking with status history |
| order_items | id, order_id, product_id, variation_id, quantity, price | Line items per order |
| users | id, name, email, password_hash, role, role_id | Customer & admin accounts |
| cart_items | id, session_id, user_id, product_id, variation_id, quantity | Persistent session-based cart |
Extended Feature Tables
| Table | Purpose | Table | Purpose |
|---|---|---|---|
| wishlists | Saved products per user | reviews | Product ratings & moderation |
| coupons | Discount codes with expiry | addresses | Multi-address per user |
| banners | Homepage carousel | blog_posts | Content marketing |
| pages | CMS pages (About, FAQ) | faqs | Structured FAQ section |
| newsletter_subscribers | Email marketing list | contact_submissions | Contact form storage |
| support_tickets | Customer support system | email_queue | Async email delivery |
| activity_logs | Admin action audit trail | roles | RBAC permission system |
| order_status_history | Status change audit log | settings | Key-value store config |
Persistent Shopping Cart
Session-based cart that survives page reloads. Supports product variations (size/color), quantity updates, and automatic price calculation with sale prices.
Secure Payment Gateway
Razorpay integration with HMAC-SHA256 signature verification. Server-side payment confirmation, webhook handling, and status history tracking.
User Authentication
Argon2id password hashing (OWASP recommended). Cookie-based sessions with HttpOnly, SameSite=Lax flags. Admin role verification on every request.
CSRF Protection
Double-submit cookie pattern. Token generated per session, validated on all POST requests. Protects against cross-site request forgery attacks.
Async Email Queue
Background goroutine processes email queue every 30 seconds. Retry logic (3 attempts), TLS/SSL support. Non-blocking order confirmation emails.
Search & Filtering
Real-time search suggestions via API. Category-based filtering, product comparison, and paginated results with configurable page sizes.
Wishlist System
Authenticated users can save products for later. Toggle-based add/remove with persistent storage. Visual heart icon on product cards.
Reviews & Ratings
Verified purchase reviews with star ratings. Admin moderation queue for approval/rejection. Average rating calculation on product pages.
Coupon Engine
Percentage or fixed-amount discounts. Minimum order thresholds, usage limits, and expiration dates. Real-time coupon validation at checkout.
Blog & CMS
Admin-managed blog posts and static pages. SEO-friendly slugs, meta descriptions. Rich content editing with HTML support.
Support Ticket System
Full ticket lifecycle: create, reply, status updates. Email notifications on replies. Admin-side ticket management with assignment.
Admin Dashboard & Reports
Real-time stats: revenue, orders, products. Sales reports with date filtering, CSV export. Activity logs for admin action auditing.
Customer Purchase Journey
Why Customers Stay
Session Management: Cookie-based with 7-day expiry for admin
Role Verification: DB check on every admin request
Session Expiry: Timestamp-based with auto-clear
Token: 32-byte random hex per session
Validation: Cookie + Form/Header match
Scope: All POST requests validated
JS Access: HttpOnly=false for AJAX reads
Payment: HMAC-SHA256 signature verification
Cookies: HttpOnly + SameSite=Lax
XSS: Go auto-escapes template output
SQL: Parameterized queries via sqlx
func ValidateCSRF(r *http.Request) bool { if r.Method != "POST" { return true } tokenCookie := GetCSRFToken(r) tokenForm := r.FormValue("csrf_token") tokenHeader := r.Header.Get("X-CSRF-Token") if tokenCookie == "" { return false } submitted := tokenForm if submitted == "" { submitted = tokenHeader } return submitted != "" && submitted == tokenCookie }
go build -o avrfashionwear.exe cmd/web/main.goProduces a single ~12MB Windows executable (or ~8MB Linux binary). No
node_modules, no vendor runtime, no interpreter.
Cross-compile for any OS/architecture with GOOS/GOARCH.
.env file with 12-factor app pattern:APP_PORT=3000, DB_HOST=127.0.0.1, DB_PORT=3306No code changes needed for environment switching. Development, staging, and production use the same binary.
migrations/.Schema versioning from initial setup through ticket system, roles/permissions, and activity logs. Run manually or via setup script.
log package.
Server output, errors, and email queue status logged to files.
Activity log table tracks admin actions for audit compliance.
# Install dependencies go mod download # Setup database (creates DB, tables, sample data) go run cmd/setup/main.go # Run development server go run cmd/web/main.go # Build production binary go build -o avrfashionwear.exe cmd/web/main.go # Cross-compile for Linux GOOS=linux GOARCH=amd64 go build -o avrfashionwear cmd/web/main.go # Run with race detector (development) go run -race cmd/web/main.go
Investment Includes
| Scope | Status |
|---|---|
| UI/UX Design & Design Implementation | ✅ Included |
| Responsive Website Development | ✅ Included |
| Product / Catalog Management | ✅ Included |
| Admin Panel | ✅ Included |
| Customer Management | ✅ Included |
| Order Management | ✅ Included |
| Required Form & Enquiry Modules | ✅ Included |
| WhatsApp / Contact Integration | ✅ Included |
| Mobile, Tablet & Desktop Optimization | ✅ Included |
| Basic SEO & Technical Setup | ✅ Included |
| Testing & Quality Assurance | ✅ Included |
| Production Deployment | ✅ Included |
| Initial Technical Support | ✅ Included |
Payment Structure
| Milestone | Payment | Amount |
|---|---|---|
| Project Confirmation | 40% | ₹30,000/- |
| Development & Demo Completion | 40% | ₹30,000/- |
| Final Delivery & Deployment | 20% | ₹15,000/- |
| Total Project Investment | 100% | ₹75,000/- |