3dai-backend / README.md
Maksymilian Jankowski
seamless task tracking
14c0c90
---
title: 3DAI API Backend
emoji: 🎯
colorFrom: blue
colorTo: purple
sdk: docker
app_port: 7860
pinned: false
license: apache-2.0
---
# 3DAI API Backend
A FastAPI backend for 3D AI model generation services.
## Features
- User authentication with Supabase
- Image-to-3D conversion using Meshy AI
- Text-to-3D conversion
- Credit system for usage tracking
- Stripe integration for payments
## Environment Variables
Create a `.env` file with the following variables:
```
SUPABASE_URL=https://<your-supabase>.supabase.co
SUPABASE_KEY=<your-supabase-service-role-key>
JWT_SECRET_KEY=<your-jwt-secret-key>
OPENAI_API_KEY=<your-openai-api-key>
STRIPE_SECRET_KEY=<your-stripe-secret-key>
# Development Mode (for testing without Google login)
DEV_MODE=false
DEV_SECRET_TOKEN=dev-secret-token-change-this
DEV_USER_EMAIL=your-dev-user@example.com
DEV_USER_ID=cc310cdf-83af-48e4-a341-d6c2f3b5462d
```
## Development Mode Authentication
For local development and testing, you can bypass the normal Google OAuth flow using development mode:
1. Set `DEV_MODE=true` in your `.env` file
2. Set `DEV_SECRET_TOKEN` to a secure token of your choice
3. Set `DEV_USER_EMAIL` to the email of an existing user in your Supabase database
4. Set `DEV_USER_ID` to `cc310cdf-83af-48e4-a341-d6c2f3b5462d` (or leave unset to use default dev ID)
**Usage:**
When DEV_MODE is enabled, you can authenticate by sending the dev token in the Authorization header:
```bash
curl -H "Authorization: Bearer your-dev-secret-token" http://localhost:7860/protected-endpoint
```
**Security Note:** Only use this in development! Never enable DEV_MODE in production.
## Local Development
1. Install dependencies:
```bash
pip install -r requirements.txt
```
2. Run the development server:
```bash
uvicorn main:app --host 0.0.0.0 --port 7860 --reload
```
3. Visit http://localhost:7860/docs for API documentation
## Deployment
### Hugging Face Spaces
This app is configured to run on Hugging Face Spaces using Docker. Make sure to:
1. Set all required environment variables in your Space settings
2. Use the Docker SDK configuration
3. Set app_port to 7860
### Environment Setup for Deployment
Set these environment variables in your deployment platform:
- `SUPABASE_URL`: Your Supabase project URL
- `SUPABASE_KEY`: Your Supabase service role key
- `JWT_SECRET_KEY`: A secure random string for JWT signing
- `OPENAI_API_KEY`: Your OpenAI API key
- `STRIPE_SECRET_KEY`: Your Stripe secret key
## API Documentation
Once running, visit `/docs` for interactive API documentation.
## Testing
Run the comprehensive test suite:
```bash
python test_deployment.py
```
## License
Apache 2.0