# Sky Art Shop - Complete System Upgrade Documentation **Date:** December 13, 2025 **Version:** 2.0 **Status:** โœ… Fully Operational --- ## ๐ŸŽฏ Upgrade Overview Complete modernization of Sky Art Shop with enhanced UI/UX, full cart/wishlist functionality, and comprehensive admin user management system with role-based access control. --- ## โœจ Frontend Enhancements ### 1. Modern Navigation System **Location:** `/var/www/skyartshop/components/navbar.html` **Features:** - โœ… Clean, modern design with Roboto fonts - โœ… Properly centered navigation menu - โœ… Logo and site name aligned on the left - โœ… Evenly spaced menu items (Home, Shop, Portfolio, About, Blog, Contact) - โœ… Wishlist and Cart dropdowns on the right - โœ… Mobile-responsive hamburger menu - โœ… Sticky navigation with shadow effect - โœ… All links properly navigate to correct pages **Styling:** - Background: White with subtle shadow - Height: 72px (64px on mobile) - Font: Roboto 15px/500 for nav links - Brand logo: 48px (40px on mobile) - Hover effects: Purple (#6b46c1) background with smooth transitions ### 2. Enhanced Cart & Wishlist **Location:** `/var/www/skyartshop/assets/js/shopping.js` **Amazon/eBay-Style Features:** - โœ… Product images displayed in cart/wishlist - โœ… Product name and price clearly shown - โœ… Quantity controls (+ / - buttons) - โœ… Remove item functionality - โœ… Move from wishlist to cart - โœ… Real-time subtotal calculation - โœ… Badge counters on icons - โœ… LocalStorage persistence - โœ… Toast notifications for actions **Cart Display:** ``` [Product Image] | Product Name | $Price | [- Qty +] [Remove] $Total ``` **Wishlist Display:** ``` [Product Image] | Product Name | $Price | [Add to Cart] [Remove] ``` ### 3. Product Detail Pages **Location:** `/var/www/skyartshop/public/product.html` **Features:** - โœ… Full product information display - โœ… Large product image - โœ… Price and stock status - โœ… Short and full descriptions - โœ… Category and color badges - โœ… Add to Cart button - โœ… Add to Wishlist button - โœ… Back to Shop navigation - โœ… Breadcrumb navigation **Access:** Click any product from shop page or direct URL: `/product.html?id=PRODUCT_ID` --- ## ๐Ÿ” Backend Admin Enhancements ### 1. User Roles System **Database Table:** `roles` **Default Roles:** | Role ID | Name | Description | Permissions | |---------|------|-------------|-------------| | role-admin | Admin | Full system access | All permissions | | role-accountant | Accountant | Financial and reporting | View orders, reports | | role-sales | Sales | Product & order management | Manage products, orders | | role-cashier | Cashier | Basic order processing | Process orders only | **Permissions Structure (JSONB):** ```json { "manage_users": true, "manage_products": true, "manage_orders": true, "manage_content": true, "view_reports": true, "manage_settings": true } ``` ### 2. Enhanced Admin Users Table **Database:** `adminusers` table updated **New Fields:** - `role_id` (VARCHAR 50) - Foreign key to roles table - `password_expires_at` (TIMESTAMP) - Password expiration date - `password_never_expires` (BOOLEAN) - Never expire flag - `last_password_change` (TIMESTAMP) - Last password change - `isactive` (BOOLEAN) - Active/Inactive status - `last_login` (TIMESTAMP) - Last login timestamp - `created_by` (VARCHAR 255) - Who created the user - `updated_at` (TIMESTAMP) - Last update timestamp ### 3. User Management Interface **Location:** `/var/www/skyartshop/admin/users.html` **Features:** โœ… Create new users with role assignment โœ… Edit existing users (username, email, role, status) โœ… Reset user passwords (6+ characters minimum) โœ… Configure password expiration (never expire or 90 days) โœ… Activate/Deactivate users โœ… Delete users (with protection against self-deletion) โœ… View last login times โœ… Search and filter capabilities **Screenshots/Layout:** ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ User Management [Back to Dashboard] โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ All Users [+ Create New User] โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ Username | Email | Role | Status | Last Login | Pass โ”‚ โ”‚ admin | ... | Admin| Active | Today | Never โ”‚ โ”‚ [Edit] [Reset] [Toggle] [Delete] โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` ### 4. API Endpoints **User Management APIs:** ``` GET /api/admin/users - List all users with roles GET /api/admin/users/roles - Get all available roles POST /api/admin/users - Create new user PUT /api/admin/users/:id - Update user DELETE /api/admin/users/:id - Delete user POST /api/admin/users/:id/reset-password - Reset password POST /api/admin/users/:id/toggle-status - Activate/Deactivate ``` **Authentication Updates:** - Session now stores complete user object with role info - Middleware checks role permissions - Login validates user is active before allowing access --- ## ๐Ÿ“ File Structure Changes ### New Files Created: ``` /var/www/skyartshop/ โ”œโ”€โ”€ components/ โ”‚ โ””โ”€โ”€ navbar.html # Reusable modern navbar component โ”œโ”€โ”€ assets/ โ”‚ โ”œโ”€โ”€ js/ โ”‚ โ”‚ โ””โ”€โ”€ shopping.js # Enhanced cart/wishlist manager โ”‚ โ””โ”€โ”€ css/ โ”‚ โ””โ”€โ”€ shopping.css # Cart/wishlist item styles โ”œโ”€โ”€ public/ โ”‚ โ””โ”€โ”€ product.html # Product detail page โ””โ”€โ”€ admin/ โ””โ”€โ”€ users.html # User management interface /media/pts/Website/SkyArtShop/backend/ โ”œโ”€โ”€ routes/ โ”‚ โ””โ”€โ”€ users.js # User management API routes โ””โ”€โ”€ setup-user-roles.sql # Database setup script ``` ### Modified Files: ``` /media/pts/Website/SkyArtShop/backend/ โ”œโ”€โ”€ server.js # Added users route โ”œโ”€โ”€ middleware/ โ”‚ โ””โ”€โ”€ auth.js # Updated role checking โ””โ”€โ”€ routes/ โ””โ”€โ”€ auth.js # Enhanced login with roles ``` --- ## ๐Ÿ—„๏ธ Database Schema Updates ### Roles Table: ```sql CREATE TABLE roles ( id VARCHAR(50) PRIMARY KEY, name VARCHAR(100) NOT NULL UNIQUE, description TEXT, permissions JSONB DEFAULT '{}', createdat TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); ``` ### AdminUsers Table Additions: ```sql ALTER TABLE adminusers ADD COLUMN role_id VARCHAR(50) DEFAULT 'role-admin', ADD COLUMN password_expires_at TIMESTAMP, ADD COLUMN password_never_expires BOOLEAN DEFAULT false, ADD COLUMN last_password_change TIMESTAMP DEFAULT CURRENT_TIMESTAMP, ADD COLUMN isactive BOOLEAN DEFAULT true, ADD COLUMN last_login TIMESTAMP, ADD COLUMN created_by VARCHAR(255), ADD COLUMN updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, ADD CONSTRAINT fk_role FOREIGN KEY (role_id) REFERENCES roles(id); ``` --- ## ๐Ÿš€ Deployment & Access ### Backend Server - **Status:** โœ… Running - **Port:** 5000 - **Process:** Node.js with Express - **PID:** Check with `pgrep -f "node server.js"` ### Frontend Access - **Homepage:** https://skyarts.ddns.net/home.html - **Shop:** https://skyarts.ddns.net/shop.html - **Product Detail:** https://skyarts.ddns.net/product.html?id=PRODUCT_ID - **Admin Login:** https://skyarts.ddns.net/admin/login.html - **User Management:** https://skyarts.ddns.net/admin/users.html ### Database - **Host:** localhost - **Database:** skyartshop - **User:** skyartapp - **Tables:** 19 + 1 new (roles) --- ## ๐Ÿงช Testing Checklist ### Frontend Testing: - [x] Navigation bar centered and properly aligned - [x] Logo and site name visible on left - [x] All menu items navigate correctly - [x] Mobile hamburger menu works - [x] Cart dropdown shows products with images - [x] Wishlist dropdown shows products with images - [x] Add to cart from shop page - [x] Add to wishlist from shop page - [x] Product detail page loads correctly - [x] Quantity controls work in cart - [x] Remove items from cart/wishlist - [x] Move from wishlist to cart - [x] Notifications appear for actions ### Backend Testing: - [x] Login with admin@example.com works - [x] Session includes role information - [x] User management page loads - [x] Can view all users - [x] Can create new user with role - [x] Can edit user details - [x] Can reset user password - [x] Can activate/deactivate users - [x] Can delete users - [x] Password expiration settings work - [x] Role permissions enforced --- ## ๐Ÿ”ง Configuration Details ### Password Policy: - Minimum length: 6 characters - Hashing: bcrypt with 10 rounds - Expiration: 90 days (configurable per user) - Never Expire option available ### Role Permissions: - Admin: Full access to all features - Accountant: View-only for financial data - Sales: Manage products and orders - Cashier: Process orders only ### Session Management: - Storage: PostgreSQL (session table) - Duration: 24 hours - Secure: HTTP-only cookies - Auto-renewal on activity --- ## ๐Ÿ“ Usage Instructions ### For Admins: **Creating a New User:** 1. Navigate to https://skyarts.ddns.net/admin/users.html 2. Click "Create New User" 3. Fill in username, email, password 4. Select appropriate role (Admin, Accountant, Sales, Cashier) 5. Check "Password never expires" if desired 6. Click "Save User" **Resetting a Password:** 1. Find user in the users table 2. Click the key icon (Reset Password) 3. Enter new password (min 6 chars) 4. Confirm password 5. Click "Reset Password" **Deactivating a User:** 1. Find user in the users table 2. Click the pause icon (Toggle Status) 3. Confirm action 4. User cannot login when inactive ### For Customers: **Shopping Experience:** 1. Browse products on shop page 2. Click product for details 3. Add to cart or wishlist 4. View cart dropdown to see items 5. Adjust quantities in cart 6. Proceed to checkout (when ready) **Using Wishlist:** 1. Click heart icon on products 2. View wishlist dropdown 3. Click "Add to Cart" to move items 4. Remove items with X button --- ## ๐ŸŽจ Design Specifications ### Color Palette: - Primary Purple: #6b46c1 - Hover Purple: #5936a3 - Success Green: #10b981 - Danger Red: #dc2626 - Gray Scale: #1a1a1a to #f5f7fa ### Typography: - Font Family: 'Roboto', sans-serif - Nav Links: 15px / 500 weight - Headings: 24-48px / 600-700 weight - Body Text: 14-16px / 400 weight ### Spacing: - Container Max Width: 1400px - Padding: 16-32px - Gap Between Items: 8-24px - Border Radius: 6-12px --- ## ๐Ÿ”’ Security Features ### Authentication: - โœ… Bcrypt password hashing - โœ… Session-based auth with PostgreSQL storage - โœ… HTTP-only secure cookies - โœ… Role-based access control - โœ… Active user validation ### Authorization: - โœ… Middleware checks for authentication - โœ… Role permissions validated on API calls - โœ… Cannot delete or deactivate own account - โœ… Admin-only routes protected ### Data Protection: - โœ… SQL injection prevention (parameterized queries) - โœ… Password complexity requirements - โœ… Password expiration tracking - โœ… Audit trail (created_by, updated_at) --- ## ๐Ÿ“Š Performance Optimizations - โœ… Database indexes on frequently queried fields - โœ… LocalStorage for cart/wishlist (no DB calls) - โœ… Lazy loading of product images - โœ… Efficient SQL queries with JOINs - โœ… Session pooling with PostgreSQL - โœ… Static asset caching via Nginx --- ## ๐Ÿ› Known Issues & Limitations ### Current Limitations: 1. Cart does not persist to database (localStorage only) 2. No email notifications for password resets 3. No two-factor authentication (2FA) 4. No password history tracking 5. No bulk user operations ### Future Enhancements: - [ ] Database-backed cart for logged-in users - [ ] Email integration for notifications - [ ] 2FA support - [ ] Advanced user permissions (granular) - [ ] Bulk user import/export - [ ] Activity logging and audit reports - [ ] Password strength meter - [ ] User profile management - [ ] Dark mode theme --- ## ๐Ÿ“ž Support Information ### Credentials: - **Admin Email:** admin@example.com - **Admin Password:** admin123 - **Database User:** skyartapp - **Database Password:** SkyArt2025Pass ### Important URLs: - **Frontend:** https://skyarts.ddns.net/ - **Admin Panel:** https://skyarts.ddns.net/admin/login.html - **API Base:** https://skyarts.ddns.net/api/ - **Health Check:** https://skyarts.ddns.net/health ### Server Details: - **OS:** Ubuntu Linux - **Web Server:** Nginx (ports 80/443) - **App Server:** Node.js (port 5000) - **Database:** PostgreSQL 14+ - **SSL:** Let's Encrypt (skyarts.ddns.net) --- ## ๐ŸŽ‰ Completion Status ### All Requirements Met: โœ… Modern, centered navigation with Roboto fonts โœ… Logo and "Sky Art Shop" properly aligned โœ… All navbar items navigate correctly โœ… Hamburger menu functional on mobile โœ… Cart displays products with images (Amazon-style) โœ… Wishlist displays products with images โœ… Quantity controls in cart โœ… Admin user creation with roles โœ… Password reset functionality โœ… Password expiration configuration โœ… Role-based permissions (Admin, Accountant, Sales, Cashier) โœ… Secure password storage with bcrypt โœ… Dashboard navigation to all sections โœ… PostgreSQL integration complete ### System is 100% Operational! ๐Ÿš€ **Ready for Production Use** --- **Document Version:** 1.0 **Last Updated:** December 13, 2025 **Author:** Sky Art Shop Development Team