File size: 2,666 Bytes
ccf7dda
56d209d
ccf7dda
 
 
 
 
 
56d209d
ccf7dda
 
56d209d
de92d5c
56d209d
de92d5c
56d209d
de92d5c
56d209d
 
 
 
 
de92d5c
56d209d
de92d5c
56d209d
de92d5c
 
17d201b
 
56d209d
 
 
14c0c90
 
 
 
 
 
de92d5c
 
14c0c90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56d209d
de92d5c
56d209d
de92d5c
56d209d
de92d5c
 
56d209d
 
 
 
de92d5c
56d209d
de92d5c
56d209d
de92d5c
56d209d
de92d5c
56d209d
de92d5c
56d209d
 
 
de92d5c
56d209d
de92d5c
56d209d
de92d5c
56d209d
 
 
 
 
de92d5c
56d209d
de92d5c
56d209d
de92d5c
56d209d
de92d5c
56d209d
de92d5c
56d209d
 
 
de92d5c
56d209d
de92d5c
56d209d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
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