| 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