Static Demo HTML served from Go Backend
Overview
The static HTML demo (with improved modal UI) is now served directly from the Go backend at the /demo/ route, while the main Vue.js SPA continues to run at the root path.
Architecture
┌─────────────────────────────────────────────────────────────────────┐
│ Browser Requests │
└────────────────────────┬─────────────────────┬──────────────────────┘
│ │
│ │
┌────▼─────┐ ┌─────▼──────┐
│ / │ │ /demo/ │
│ Vue.js │ │ Static │
│ SPA │ │ HTML │
└────┬─────┘ └─────┬──────┘
│ │
│ │
┌────▼─────────────────────▼──────┐
│ Nginx (Port 80) │
│ • Serves Vue.js from /dist │
│ • Proxies /demo/ to Go │
│ • Proxies /api/ to Go │
│ • Proxies /ws to Go │
└────┬────────────────────┬────────┘
│ │
│ │
┌────▼────────────────────▼────────┐
│ Go MCP Server (Port 8080) │
│ • REST API (/api/*) │
│ • WebSocket (/ws) │
│ • Static Demo (/demo/) │
│ • File Server (web/static/) │
└──────────────────────────────────┘
Endpoints
Production Vue.js App
- URL:
http://localhost/ - Description: Modern Vue.js 3 Single Page Application
- Features:
- Tailwind CSS styling
- Vue Router for navigation
- Pinia state management
- WebSocket integration
- Responsive design
Static HTML Demo
- URL:
http://localhost/demo/ - URL (Direct):
http://localhost:8080/demo/ - Description: Static HTML with improved modal UI
- Features:
- Modern modal design
- Improved form styling
- CSS animations
- Vanilla JavaScript
API Access
- URL:
http://localhost/api/* - Description: REST API endpoints
- Proxied to:
http://mcp-server:8080/api/*
WebSocket
- URL:
ws://localhost/ws?project_id=<uuid> - Description: Real-time communication
- Proxied to:
ws://mcp-server:8080/ws
File Structure
agent-shaker/
├── web/
│ ├── src/ # Vue.js app source (Served at /)
│ │ ├── App.vue
│ │ ├── main.js
│ │ ├── components/
│ │ ├── views/
│ │ └── stores/
│ │
│ ├── static/ # Static HTML (Served at /demo/)
│ │ ├── index.html # Main demo page
│ │ ├── app.js # Vanilla JavaScript
│ │ └── style.css # CSS with modal improvements
│ │
│ ├── dist/ # Built Vue.js (generated)
│ ├── Dockerfile # Builds Vue.js app
│ └── nginx.conf # Nginx configuration
│
└── cmd/server/main.go # Go backend with static file server
Implementation Details
Go Backend (main.go)
// Static demo HTML (for testing/demo purposes)
staticDir := http.Dir("web/static")
staticHandler := http.StripPrefix("/demo/", http.FileServer(staticDir))
r.PathPrefix("/demo/").Handler(staticHandler)
The Go server:
- Creates a file server for the
web/staticdirectory - Strips the
/demo/prefix from URLs - Serves files from
web/static/
Example URL mapping:
http://localhost:8080/demo/→web/static/index.htmlhttp://localhost:8080/demo/app.js→web/static/app.jshttp://localhost:8080/demo/style.css→web/static/style.css
Nginx Configuration (nginx.conf)
# Static demo HTML served from Go backend
location /demo/ {
proxy_pass http://mcp-server:8080;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
Nginx:
- Intercepts requests to
/demo/* - Proxies them to the Go backend
- Sets proper headers for logging and security
Docker Integration
The web/static folder is copied into the Go container during build:
# In Dockerfile (mcp-server stage)
COPY web ./web
This ensures the static files are available inside the container at /app/web/static/.
Why Two Frontends?
Vue.js App (Production)
- Purpose: Main production application
- Benefits:
- Component-based architecture
- State management
- TypeScript support
- Hot module replacement in dev
- Optimized production builds
Static HTML (Demo/Testing)
- Purpose: Quick testing, demos, backward compatibility
- Benefits:
- No build step required
- Easy to modify and test
- Vanilla JavaScript - no frameworks
- Can serve as documentation/examples
API Interaction
Both frontends interact with the same Go backend API:
// In static/app.js
const API_BASE = window.location.origin + '/api';
const WS_BASE = 'ws://' + window.location.host + '/ws';
// Same endpoints work for both:
fetch(`${API_BASE}/projects`) // Works from / and /demo/
Development Workflow
Modifying Vue.js App
- Edit files in
web/src/ - Rebuild:
docker-compose up -d --build web - Access at:
http://localhost/
Modifying Static Demo
- Edit files in
web/static/ - Rebuild:
docker-compose up -d --build mcp-server - Access at:
http://localhost/demo/
Note: Static files are copied into the Go container, so changes require rebuilding the mcp-server service.
Testing
Test Vue.js App
Invoke-WebRequest -Uri http://localhost/ -UseBasicParsing
Test Static Demo
Invoke-WebRequest -Uri http://localhost/demo/ -UseBasicParsing
Test Direct Backend Access
# Via Nginx (recommended)
Invoke-WebRequest -Uri http://localhost/demo/ -UseBasicParsing
# Direct to Go server (bypass Nginx)
Invoke-WebRequest -Uri http://localhost:8080/demo/ -UseBasicParsing
Logs
Check Go Server Logs
docker-compose logs mcp-server
Expected output:
MCP API Server - Endpoints:
API: http://localhost:8080/api
WebSocket: ws://localhost:8080/ws
Health: http://localhost:8080/health
Docs: http://localhost:8080/api/docs
Static Demo: http://localhost:8080/demo/
Check Nginx Logs
docker-compose logs web
Troubleshooting
404 on /demo/ route
Problem: Getting 404 when accessing /demo/
Solutions:
- Ensure Go server includes file server code
- Verify
web/static/folder exists with files - Check Nginx proxy configuration
- Rebuild containers:
docker-compose up -d --build
Static files not updating
Problem: Changes to web/static/ files not reflected
Solution: Static files are copied during Docker build. You must rebuild:
docker-compose up -d --build mcp-server
Modal not showing improvements
Problem: Modal UI improvements not visible
Solution:
- Clear browser cache (Ctrl+Shift+Delete)
- Hard refresh (Ctrl+F5)
- Verify you're on
/demo/not/
Best Practices
-
Use Vue.js for production: The main app at
/is optimized and production-ready -
Use static demo for:
- Quick UI mockups
- Testing API changes
- Demonstrating features
- Documentation examples
-
Keep both in sync: If you add features to static demo, consider porting to Vue.js
-
Cache management: Static files served from Go may need cache headers for production
Security Considerations
- Path Traversal: The
http.FileServeris restricted toweb/static/directory - Access Control: No authentication on
/demo/- add if needed for production - CORS: Already configured in Go server for API access
- Headers: Security headers set in Nginx configuration
Future Enhancements
- Option to disable demo: Add environment variable to enable/disable
/demo/route - Hot reload: Add file watching for static files during development
- CDN integration: Serve static assets from CDN in production
- Authentication: Add auth middleware if demo contains sensitive data
Summary
✅ Vue.js SPA: http://localhost/ - Production application
✅ Static Demo: http://localhost/demo/ - Testing and demos
✅ Go Backend: Serves both static files and API
✅ Nginx: Proxies both routes appropriately
✅ Clean Architecture: Separation of concerns maintained