--- title: AcadFlow Backend emoji: 🎓 colorFrom: indigo colorTo: purple sdk: docker app_port: 5000 pinned: false --- # AcadFlow Backend - Hugging Face Spaces Deployment ## 🚀 Deploy to Hugging Face Spaces ### Step-by-Step Upload 1. **Go to** [huggingface.co/spaces/Vijayadhith7/acadflow](https://huggingface.co/spaces/Vijayadhith7/acadflow) 2. **Click** the **Files** tab 3. **Upload** all files from this `deploy-backend` folder - Upload everything EXCEPT `credentials.json` and `.env.example` - The `Dockerfile` tells HF how to build and run the app ### ⚙️ Environment Variables (CRITICAL - Set as Secrets) Go to **Settings → Repository Secrets** and add: | Secret Name | Value | |-------------|-------| | `PORT` | `5000` | | `SUPABASE_URL` | `https://wmmcziautjlelocrprms.supabase.co` | | `SUPABASE_KEY` | `sb_publishable_G80nBYUkRqC3j2X6sevnnQ_9glfZ1dT` | | `SPREADSHEET_ID` | `1-FuEPAmLyBQFu5V3of6bY6IiF7FWiD1_-QAp0lvLCWY` | | `GOOGLE_CREDS_JSON` | *(see below)* | ### 🔑 Setting GOOGLE_CREDS_JSON The `credentials.json` file contains your Google Service Account keys. For Hugging Face: 1. Open the `credentials.json` file in this folder 2. Copy the **entire contents** (the full JSON object) 3. Minify it to a single line (remove newlines) — you can use [jsonminify.com](https://www.jsonminify.com) 4. Paste the minified JSON as the value of `GOOGLE_CREDS_JSON` secret in HF Settings **Example** (shortened): ``` {"type":"service_account","project_id":"academy-dashboard-497400","private_key_id":"b7174c...","private_key":"-----BEGIN PRIVATE KEY-----\nMIIEv...","client_email":"id-academy-crm-dashboard@academy-dashboard-497400.iam.gserviceaccount.com",...} ``` ### 🔌 Port Configuration - The app runs on port **5000** (not 7860, since your Aura project uses that) - Hugging Face will automatically proxy to whatever port your container exposes - Make sure `PORT=5000` is set in your HF Secrets ### 📁 Structure ``` deploy-backend/ ├── Dockerfile # HF Spaces Docker build config ├── .env.example # Environment variable template (DON'T upload this) ├── credentials.json # Google Service Account key (DON'T upload - use secrets) ├── package.json # Dependencies ├── server.js # Express + Socket.IO server ├── db.js # Supabase database client ├── notifications.json # Local notification storage ├── services/ │ ├── aiEngine.js # NVIDIA NIM AI insights engine │ └── googleSheets.js # Google Sheets sync service └── database/ ├── schema.sql # Database schema reference ├── init-db.js # Database initialization script └── ... # Other DB utility scripts ``` ### ⚠️ Important Notes - **DO NOT** upload `credentials.json` to the HF Space files — use the `GOOGLE_CREDS_JSON` secret instead - **DO NOT** upload `.env` or `.env.example` — use HF Secrets for all sensitive values - The `notifications.json` file provides initial mock notifications; it gets updated at runtime