Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

23 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Multi-AI Agentic Application Backend

This backend powers a multi-agent AI application using FastAPI, LangChain, and LangGraph. It provides robust session management, user authentication, and agent orchestration for advanced AI workflows.

Features

  • FastAPI-based RESTful API: High-performance and easy-to-use API framework.
  • User Authentication: Secure signup and login functionality using JWT.
  • Session Management: Persistent session handling for multi-agent interactions.
  • Multi-Agent Orchestration: Designed for integration with LangChain and LangGraph.
  • MongoDB Integration: Asynchronous database operations using Motor.
  • Structured Logging: Application-wide logging with configurable levels.
  • Chat & Conversations: Chat with conversation history tracking.

Tech Stack

  • Framework: FastAPI
  • AI Frameworks: LangChain, LangGraph
  • Database: MongoDB with Motor
  • Authentication: JWT (JSON Web Tokens)
  • Environment Management: python-dotenv
  • LLM Providers: Google Gemini, Groq

Project Structure

backend/
├── app/
│   ├── api/            # API Route handlers (chat, sessions, users)
│   ├── auth/           # Authentication & Security logic (JWT, hashing)
│   ├── configs/        # App configurations
│   ├── db/             # Database connection & setup
│   ├── graphs/         # LangGraph workflows for AI agents
│   ├── persistance/    # Repositories for DB interactions
│   ├── schemas/        # Pydantic models for validation
│   ├── services/       # Business logic (chat, LLM, web search)
│   ├── utils/          # Helper functions (logger, error handlers)
│   └── main.py         # Entry point of the application
├── .env.example        # Example environment variables
├── requirements.txt    # Python dependencies

Getting Started

Prerequisites

Installation

  1. Navigate to the backend directory:

    cd backend
  2. Create and activate a virtual environment:

    python -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt

Configuration

Create a .env file in the backend directory and add your configurations (refer to .env.example):

# Database Configuration
MONGODB_URL=mongodb://localhost:27017
MONGODB_DB_NAME=aiagent

# Authentication
SECRET_KEY=your_super_secret_key_change_this
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=60

# LLM Provider API Keys (at least one required)
GOOGLE_API_KEY=your-google-api-key-here
GROQ_API_KEY=your-groq-api-key-here

# Web Search API Key
TAVILY_API_KEY=your-tavily-api-key-here

Required Environment Variables:

  • MONGODB_URL - MongoDB connection string
  • MONGODB_DB_NAME - Database name
  • SECRET_KEY - Secret key for JWT token generation (use a strong random string)
  • At least one LLM provider key (GOOGLE_API_KEY or GROQ_API_KEY)
  • TAVILY_API_KEY - For web search functionality

Running the Application

Start the development server:

python app/main.py

The API will be available at http://localhost:8000. You can access the Interactive API docs (Swagger UI) at http://localhost:8000/docs.

API Endpoints

Health & Info

Method Endpoint Description Auth Required
GET / Root endpoint with API information ❌
GET /agent/health Health check endpoint ❌

User Authentication

Method Endpoint Description Auth Required
POST /agent/users/signup Create a new user account ❌
POST /agent/users/login Authenticate user and get JWT token ❌

Session Management

Method Endpoint Description Auth Required
POST /agent/sessions/create Create a new agent session ✅

Chat & Conversations

Method Endpoint Description Auth Required
POST /agent/chat/messages Send a message to AI agent and get response ✅
GET /agent/chat/conversations/{session_id}/messages Get conversation history for a session ✅

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages