| title | AIVerse Backend |
|---|---|
| emoji | 🤖 |
| colorFrom | blue |
| colorTo | green |
| sdk | docker |
| app_port | 7860 |
A production-ready FastAPI backend for AI applications with modular architecture.
- ✅ RESTful API design
- ✅ Automatic API documentation
- ✅ Environment-based configuration
- ✅ Modular router structure
- ✅ Service layer pattern
- ✅ Pydantic data validation
- ✅ CORS support
- 🔜 AI model integration (Ollama, GROQ)
- 🔜 Database integration
- 🔜 Authentication & authorization
fastapi/ ├── app/ # Main application package │ ├── api/ # API routes │ ├── core/ # Core functionality │ ├── models/ # Pydantic models │ ├── services/ # Business logic │ └── utils/ # Utilities ├── tests/ # Test files ├── .env # Environment variables ├── requirements.txt # Dependencies └── main.py # Entry point frontend/ docs/ commands.txt widget-demo.html
cd fastapipython -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txtcp .env.example .env
# Edit .env with your settings# Method 1: Using uvicorn directly
uvicorn main:app --reload
# Method 2: Using Python
python main.pycd frontendnpm installcp .env.example .env
# Edit .env with your settingsnpm run dev
Once running, visit:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
- OpenAPI JSON: http://localhost:8000/openapi.json
GET /api/v1/health- Health check
POST /api/v1/users- Create userGET /api/v1/users- List usersGET /api/v1/users/{id}- Get userPATCH /api/v1/users/{id}- Update userDELETE /api/v1/users/{id}- Delete userGET /api/v1/users/stats/count- User statistics
See .env.example for all available configuration options.
Key variables:
DEBUG: Enable debug modeENVIRONMENT: Environment name (development/production)API_V1_PREFIX: API version prefixALLOWED_ORIGINS: CORS allowed origins
AIVerse now supports multiple AI providers with a unified interface:
| Provider | Cost | Speed | Quality | Free Tier |
|---|---|---|---|---|
| Ollama | Free | Fast* | Good | ✅ Unlimited |
| Groq | Very Low | Very Fast | Good | ✅ 30 req/min |
*With GPU
# Use Groq for fast inference
response = await ai_service.chat(
provider="groq",
model="llama-3.3-70b-versatile",
messages=[{"role": "user", "content": "Hello!"}]
)
# Use Ollama for free unlimited usage
response = await ai_service.chat(
provider="ollama",
model="llama2",
messages=[{"role": "user", "content": "Write a poem"}]
)- ✅ Unified Interface - Same API for all providers
- ✅ Cost Tracking - Monitor spending across providers
- ✅ Budget Limits - Set monthly spending caps
- ✅ Usage Dashboard - Real-time usage statistics
- Groq: https://console.groq.com/keys (Free tier available)
- Follow the existing code structure
- Add tests for new features
- Update documentation
- Use type hints
MIT