Spaces:
Build error
π Domify Academy Super Bot - Complete Setup & Deployment Guide
π¦ What You're Getting
A production-ready, full-stack AI chatbot with:
β Backend (FastAPI + NVIDIA API)
- Llama-3 70B LLM with smart fallback chain
- SDXL/Flux image generation
- DuckDuckGo search integration
- DeepSeek-style reasoning
- Rate limiting & monitoring
- Google Sheets feedback logging
β Frontend (React 19 + TypeScript)
- Dark glassmorphism UI (21dev theme)
- Ask | Imagine mode switcher
- Chat sidebar with local storage
- Advanced prompt input (Search/Think toggles)
- Collapsible reasoning panel
- Rich markdown rendering
- Image gallery with download
- File upload & OCR ready
β Deployment
- Dockerfile for Hugging Face Spaces
- Environment configuration
- Complete documentation
π₯ Step 1: Download & Extract Code
Download the complete code:
wget https://files.manuscdn.com/user_upload_by_module/session_file/310519663512731124/eepQdzwGxcStVZQg.gz -O complete-code.tar.gz
tar -xzf complete-code.tar.gz
cd domify-academy-bot
π§ Step 2: Setup Backend (Local Testing)
Install Dependencies
pnpm install
Create Environment File
Create .env file in project root:
# Database
DATABASE_URL=mysql://user:password@localhost:3306/domify_bot
# NVIDIA API
NVIDIA_API_KEY=your_nvidia_api_key_here
# JWT & OAuth
JWT_SECRET=your_jwt_secret_here
OAUTH_SERVER_URL=https://api.manus.im
VITE_OAUTH_PORTAL_URL=https://manus.im
# App Config
VITE_APP_ID=your_app_id
VITE_APP_TITLE=Domify Academy Bot
VITE_APP_LOGO=https://your-logo-url.png
# Frontend API
REACT_APP_API_URL=http://localhost:3000
Run Backend Locally
pnpm run dev
Server will run on http://localhost:3000
π¨ Step 3: Setup Frontend (Local Testing)
Frontend is included in the same project
The frontend automatically starts with the backend. Access it at:
http://localhost:3000/chat
Update API Endpoint (if needed)
Edit client/src/pages/Chat.tsx:
const API_BASE_URL = process.env.REACT_APP_API_URL || "http://localhost:3000";
π Step 4: Deploy to Hugging Face Spaces
4.1 Create Hugging Face Space
- Go to huggingface.co/spaces
- Click "Create new Space"
- Select "Docker" SDK
- Name:
domify-academy-bot - Choose "Public" (or Private)
- Click "Create Space"
4.2 Push Code to Hugging Face
# Initialize git (if not already done)
git init
git add .
git commit -m "Initial Domify Academy Bot deployment"
# Add Hugging Face remote
git remote add origin https://huggingface.co/spaces/YOUR_USERNAME/domify-academy-bot
# Push to Hugging Face
git push -u origin main
Note: Replace YOUR_USERNAME with your Hugging Face username.
4.3 Set Environment Variables in Space
- Go to your Space settings
- Find "Variables and secrets" section
- Add these secrets:
| Key | Value | Description |
|---|---|---|
DATABASE_URL |
mysql://... |
Your MySQL connection string |
NVIDIA_API_KEY |
your_key_here |
NVIDIA API key |
JWT_SECRET |
generate_with_openssl |
openssl rand -base64 32 |
OAUTH_SERVER_URL |
https://api.manus.im |
OAuth server URL |
VITE_OAUTH_PORTAL_URL |
https://manus.im |
OAuth portal URL |
VITE_APP_ID |
your_app_id |
Application ID |
VITE_APP_TITLE |
Domify Academy Bot |
App title |
REACT_APP_API_URL |
https://YOUR_SPACE_URL |
Your Space URL |
4.4 Wait for Build
Hugging Face will automatically:
- Detect the Dockerfile
- Build the Docker image
- Deploy the application
This takes 5-10 minutes. You'll see a "Building" status.
4.5 Access Your Bot
Once deployed, your bot will be available at:
https://YOUR_USERNAME-domify-academy-bot.hf.space
π File Structure
domify-academy-bot/
βββ client/ # Frontend (React)
β βββ src/
β β βββ pages/
β β β βββ Chat.tsx # Main chat interface (Ask/Imagine)
β β β βββ Home.tsx # Landing page
β β β βββ NotFound.tsx # 404 page
β β βββ components/
β β β βββ ChatSidebar.tsx # Sidebar with chat history
β β βββ App.tsx # Routes & layout
β β βββ main.tsx # React entry
β β βββ index.css # Global styles (glassmorphism)
β βββ index.html # HTML template
β βββ public/ # Static assets
βββ server/ # Backend (Express + tRPC)
β βββ llm.ts # NVIDIA LLM integration
β βββ search.ts # DuckDuckGo search
β βββ rateLimit.ts # Rate limiting
β βββ db.ts # Database helpers
β βββ googleSheets.ts # Google Sheets integration
β βββ middleware.ts # Logging, caching, monitoring
β βββ routers.ts # tRPC procedures
β βββ _core/ # Framework internals
βββ drizzle/ # Database schema & migrations
β βββ schema.ts # Table definitions
β βββ migrations/ # SQL migrations
βββ Dockerfile # Docker build config
βββ DEPLOYMENT.md # Deployment guide
βββ BACKEND_README.md # Backend documentation
βββ FRONTEND_SETUP.md # Frontend documentation
βββ QUICKSTART.md # 5-minute setup
βββ package.json # Dependencies
π Environment Variables Explained
Backend Variables
| Variable | Purpose | Example |
|---|---|---|
DATABASE_URL |
MySQL connection | mysql://user:pass@host/db |
NVIDIA_API_KEY |
NVIDIA API key | nvapi-... |
JWT_SECRET |
Session signing | base64_random_string |
OAUTH_SERVER_URL |
OAuth provider | https://api.manus.im |
Frontend Variables
| Variable | Purpose | Example |
|---|---|---|
REACT_APP_API_URL |
Backend API URL | https://your-space.hf.space |
VITE_APP_TITLE |
App title | Domify Academy Bot |
VITE_APP_LOGO |
Logo URL | https://...logo.png |
π§ͺ Testing Locally
Test Backend API
# Start dev server
pnpm run dev
# In another terminal, test chat endpoint
curl -X POST http://localhost:3000/api/trpc/chat.send \
-H "Content-Type: application/json" \
-d '{
"prompt": "Hello, how are you?",
"enableSearch": false,
"enableThinking": false,
"history": []
}'
Test Frontend
- Open
http://localhost:3000/chat - Try Ask mode:
- Type a message
- Click Send
- See response appear
- Try Imagine mode:
- Switch to Imagine
- Type image description
- Click "Generate Image"
- Test sidebar:
- Create multiple chats
- Switch between them
- Delete a chat
- Verify local storage persistence
π Troubleshooting
Backend Won't Start
Error: Cannot find module 'express'
Solution:
pnpm install
pnpm run dev
Database Connection Failed
Error: ECONNREFUSED 127.0.0.1:3306
Solution:
- Ensure MySQL is running
- Check
DATABASE_URLis correct - Verify credentials
Frontend Not Loading
Error: 404 Not Found or blank page
Solution:
- Check dev server is running:
pnpm run dev - Clear browser cache
- Check browser console for errors
API Endpoint Not Working
Error: Failed to fetch or CORS error
Solution:
- Verify
REACT_APP_API_URLis correct - Check backend is running
- Ensure CORS is enabled on backend
- Check network tab in browser DevTools
Hugging Face Build Failed
Error: Docker build error
Solution:
- Check Dockerfile syntax
- Verify all environment variables are set
- Check Space logs for detailed error
- Try rebuilding the Space
π± Features Walkthrough
Ask Mode
Send Message
- Type question
- Press Enter or click Send
- View response with markdown rendering
Search Online
- Click "Search Online" toggle
- Send message
- Bot will search web for context
Think Longer
- Click "Think Longer" toggle
- Send message
- View reasoning process in collapsible panel
Upload Files
- Click "Upload" button
- Select image or document
- Send message with file context
Chat History
- View all chats in sidebar
- Click to switch between chats
- Delete chats with trash icon
- All stored in browser local storage
Imagine Mode
Generate Image
- Type image description
- Click "Generate Image"
- Wait for generation
View Gallery
- Generated images appear in gallery
- Scroll horizontally to see all
- Click "Download" to save image
- "Video" button coming soon
π¨ Customization
Change Colors
Edit client/src/index.css:
.dark {
--primary: oklch(0.623 0.214 259.815); /* Violet */
--secondary: oklch(0.55 0.15 264); /* Indigo */
--accent: oklch(0.65 0.18 280); /* Light indigo */
--background: oklch(0.07 0.002 0); /* Deep black */
--foreground: oklch(0.95 0.002 0); /* Near white */
}
Change Fonts
Edit client/index.html:
<link href="https://fonts.googleapis.com/css2?family=YOUR_FONT&display=swap" rel="stylesheet">
Change App Title
Set VITE_APP_TITLE environment variable
π Database Schema
Tables
- users - User accounts
- conversations - Chat sessions
- messages - Individual messages
- generated_images - Generated images
- feedback - User feedback (logged to Google Sheets)
π Security Best Practices
- Never commit
.envfile - Use environment variables in deployment - Keep API keys secret - Use Hugging Face Spaces secrets
- Enable HTTPS - Hugging Face provides SSL automatically
- Rate limiting - Enabled by default (30 req/min per user)
- Input validation - All inputs sanitized on backend
π Performance Tips
- Cache search results - 5-minute TTL for DuckDuckGo searches
- Lazy load images - Images load on demand in gallery
- Compress responses - Gzip enabled on all API responses
- Browser caching - Chat history stored locally
- Monitor usage - Check logs for slow endpoints
π Next Steps
- β Download and extract code
- β
Test locally with
pnpm run dev - β Create Hugging Face Space
- β Set environment variables
- β Push code to Hugging Face
- β Wait for build completion
- β Access your bot at Space URL
- β Start using!
π Support
Common Issues
- Build fails: Check Dockerfile and environment variables
- API errors: Check backend logs in Space
- Frontend blank: Check browser console for errors
- Slow responses: Check NVIDIA API quota
Documentation
BACKEND_README.md- Backend API referenceFRONTEND_SETUP.md- Frontend customizationDEPLOYMENT.md- Detailed deployment guideQUICKSTART.md- 5-minute setup
π You're Ready!
Your Domify Academy Super Bot is ready to deploy. Follow the steps above and you'll have a production-ready AI chatbot running on Hugging Face Spaces in minutes!
Questions? Check the documentation files or review the code comments.
Happy coding! π