Lanvas Backend

This repo contains the code for the backend of Lanvas.

Tech Stack:

Architecture

architecture

The architecture for the chat API is based on the Official LangChain guide for RAG with Chat History with a few modifications.

Since Supabase is the database and vectorstore for Lanvas, there is a Custom Retriever and ChatHistory to make the chain work.

Celery is used to handle analytics tasks that aggregate the following:

  1. Topics discussed by a student
  2. Misconceptions of a student

The analysis is powered by Instructor and OpenAI's GPT LLM.

Setup

  1. Install poetry

  2. Install dependencies using poetry

    poetry install
  3. Install and setup RabbitMQ

  4. Install Supabase CLI

  5. Create a new Supabase project using the dashboard

  6. Link with the newly created Supabase project

    supabase link --project-ref ""
  7. Setup Tables and Functions with migrations in the supabase/migrations/ directory

    supabase db push
  8. Setup .env file

    cp .env.sample .env
  9. Activate virtual environment

    poetry shell
  10. Setup Celery worker

    celery -A celery_tasks worker -l INFO
  11. Start the FastAPI server

    uvicorn main:app --reload
  12. Visit the docs at http://localhost:8000/docs

Tests

There are a few unit tests setup which you can verify by running the following command:

poetry run pytest -s