# πŸš€ Visual Asset Manager - Backend Setup **Status**: βœ… FULLY FUNCTIONAL **Delete**: Now actually deletes files from disk **Re-roll**: API ready (image generation TBD) --- ## 🎯 QUICK START ### 1. Install Dependencies ```bash pip3 install Flask flask-cors ``` ### 2. Start Backend Server ```bash cd /Users/davidkotnik/repos/novafarma python3 tools/asset_backend.py ``` Server starts on: **http://localhost:5000** ### 3. Start Frontend Server ```bash # In another terminal: cd /Users/davidkotnik/repos/novafarma python3 -m http.server 8080 ``` Frontend URL: **http://localhost:8080/tools/visual_asset_manager.html** --- ## βœ… WHAT NOW WORKS: ### πŸ—‘οΈ DELETE (Fully Functional!) 1. Klikni "Delete" na asset cardu 2. Confirm dialog 3. **Backend dejansko izbriΕ‘e datoteko iz diska** 4. Auto-regenerira manifest 5. Galerija se osveΕΎ i **Flow:** ``` Frontend β†’ DELETE /api/asset/{id} ↓ Backend finds file ↓ os.remove() - file deleted ↓ Regenerate manifest ↓ Return success β†’ Frontend reloads ``` ### πŸ”„ RE-ROLL (API Ready) 1. Klikni "Re-roll" 2. Backend API endpoint ready 3. **TODO**: Image generation not yet implemented 4. For now: Shows placeholder message --- ## πŸ”Œ API ENDPOINTS: ### Health Check ```bash GET http://localhost:5000/api/health ``` ### Get All Assets ```bash GET http://localhost:5000/api/assets ``` ### Delete Asset ```bash DELETE http://localhost:5000/api/asset/{asset_id} Response: { "success": true, "message": "Asset deleted successfully", "deleted_file": "assets/path/to/file.png" } ``` ### Re-roll Asset ```bash POST http://localhost:5000/api/asset/{asset_id}/reroll Response: { "success": true, "message": "Re-roll requested", "note": "Image generation not yet implemented" } ``` ### Regenerate Manifest ```bash POST http://localhost:5000/api/manifest/regenerate Response: { "success": true, "message": "Manifest regenerated", "total_assets": 1166 } ``` --- ## 🎬 WORKFLOW EXAMPLE: ### Delete Unwanted Asset: 1. **Odpri galerijo**: http://localhost:8080/tools/visual_asset_manager.html 2. **Find asset**: Use search or filter 3. **Click Delete**: Red button 4. **Confirm**: Dialog asks for confirmation 5. **Wait**: Backend deletes file (2s) 6. **Auto-refresh**: Gallery shows updated list **Result**: File physically deleted from disk! --- ## πŸ› οΈ DEVELOPMENT: ### Backend Code `tools/asset_backend.py` - Flask API server ### Frontend Code `tools/visual_asset_manager.html` - Updated with API calls ### Dependencies `to ols/requirements.txt`: - Flask==3.0.0 - flask-cors==4.0.0 --- ## πŸ”’ SECURITY NOTES: ⚠️ **Development Only** - CORS is open (allows all origins) - No authentication - Debug mode enabled - NOT for production use **For production**, add: - Authentication - CORS restrictions - Rate limiting - Input validation - HTTPS --- ## πŸ› TROUBLESHOOTING: ### Backend not starting? ```bash # Check if Flask installed: pip3 show Flask # Check port 5000 available: lsof -ti:5000 # View backend logs: tail -f /tmp/backend.log ``` ### Delete not working? ```bash # Check backend is running: curl http://localhost:5000/api/health # Should return: # {"status": "ok", "message": "Asset Backend API is running"} ``` ### CORS errors? ```bash # Make sure both servers running: # Backend: localhost:5000 # Frontend: localhost:8080 ``` --- ## πŸ“Š STATUS: | Feature | Status | Notes | |---------|--------|-------| | Backend API | βœ… Running | Flask on port 5000 | | Delete Endpoint | βœ… Working | Deletes files from disk | | Re-roll Endpoint | ⚠️ API Only | Image gen not implemented | | Manifest Regen | βœ… Working | Auto-updates after delete | | Frontend Integration | βœ… Working | API calls functional | --- ## πŸš€ NEXT STEPS: 1. **Image Generation**: Integrate Gemini API for re-roll 2. **Batch Delete**: Select multiple assets 3. **Undo**: Trash bin before permanent delete 4. **Preview Changes**: Show what will be deleted 5. **Authentication**: Add user login --- **Setup Time**: ~15 min **Dependencies**: Flask, flask-cors **Ready**: YES βœ