Skip to content

junaidte14/aiverse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

title AIVerse Backend
emoji πŸ€–
colorFrom blue
colorTo green
sdk docker
app_port 7860

FastAPI AI Backend

A production-ready FastAPI backend for AI applications with modular architecture.

Features

  • βœ… 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

Project Structure

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

Setup

1. Clone and Navigate

cd fastapi

2. Create Virtual Environment

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

4. Configure Environment

cp .env.example .env
# Edit .env with your settings

5. Run the Application

# Method 1: Using uvicorn directly
uvicorn main:app --reload

# Method 2: Using Python
python main.py

Frontend (React App) Setup

1. Clone and Navigate

cd frontend

3. Install Dependencies

npm install

4. Configure Environment

cp .env.example .env
# Edit .env with your settings

5. Run the Application

npm run dev

API Documentation

Once running, visit:

API Endpoints

Health

  • GET /api/v1/health - Health check

Users

  • POST /api/v1/users - Create user
  • GET /api/v1/users - List users
  • GET /api/v1/users/{id} - Get user
  • PATCH /api/v1/users/{id} - Update user
  • DELETE /api/v1/users/{id} - Delete user
  • GET /api/v1/users/stats/count - User statistics

Environment Variables

See .env.example for all available configuration options.

Key variables:

  • DEBUG: Enable debug mode
  • ENVIRONMENT: Environment name (development/production)
  • API_V1_PREFIX: API version prefix
  • ALLOWED_ORIGINS: CORS allowed origins

πŸ€– Multi-Provider AI Support

AIVerse now supports multiple AI providers with a unified interface:

Supported Providers

Provider Cost Speed Quality Free Tier
Ollama Free Fast* Good βœ… Unlimited
Groq Very Low Very Fast Good βœ… 30 req/min

*With GPU

Quick Start

# 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"}]
)

Features

  • βœ… 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

Get API Keys

  1. Groq: https://console.groq.com/keys (Free tier available)

Contributing

  1. Follow the existing code structure
  2. Add tests for new features
  3. Update documentation
  4. Use type hints

License

MIT

About

AIVerse - A full stack AI development project using Fast API, and React.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors