Spaces:
Sleeping
Sleeping
Deploying Chatsmith to Hugging Face Spaces
This guide explains how to deploy your Chatsmith application (React Frontend + FastAPI Backend) to Hugging Face Spaces for free.
Prerequisites
- A Hugging Face account.
Steps
1. Create a New Space
- Go to Hugging Face Spaces and click Create new Space.
- Space Name: Enter a name (e.g.,
chatsmith-app). - License: Choose one (e.g.,
MIT). - SDK: Select Docker.
- Template: Select Blank.
- Visibility: Public or Private.
- Click Create Space.
2. Configure Secrets (Environment Variables)
Your app needs OpenAI and Supabase keys.
- In your Space, go to Settings.
- Scroll to the Variables and secrets section.
- Click New secret and add the following (copy from your local
.envfile):OPENAI_API_KEYSUPABASE_URLSUPABASE_ANON_KEYENABLE_METRICS_LOGGING(Set totrueto enable Supabase logging)
3. Upload Code
You can upload files via the web interface or use Git. Since you have the code locally:
Option A: Drag and Drop (Easiest for one-off)
- Go to the Files tab of your Space.
- Click Add file -> Upload files.
- Open your local
chatsmith-mainfolder. - Select all files inside (backend, frontend, Dockerfile, etc.).
- Drag and drop them into the web interface.
- Important: Do NOT drag the
chatsmith-mainfolder itself. Drag the contents. - Tip: You can skip the
node_modulesfolder if it exists, as it will be recreated by Docker.
- Important: Do NOT drag the
- Commit the changes.
Option B: Git (Recommended)
In your local terminal, initialize git if not already:
git init git add . git commit -m "Initial commit"Add the Hugging Face remote (find the command in your Space's "Clone repository" button):
git remote add space https://huggingface.co/spaces/YOUR_USERNAME/SPACE_NAMEPush to the Space:
git push --force space master:mainNote: If asked for a password, you must use a Hugging Face Access Token with
writepermissions (Settings -> Access Tokens), NOT your account password.Authentication Helper (if needed):
git config --global credential.helper store
4. Wait for Build
- Once files are uploaded, Hugging Face will automatically detect the
Dockerfileand start building. - Click the App tab to see the build logs.
- It may take a few minutes to build the frontend and install Python dependencies.
- Once "Running", your app will be live!
Troubleshooting
- Build Failed: Check the logs in the App tab.
- Runtime Error: Ensure your Secrets are set correctly in the Settings tab.