This repository contains code for the publicly accessible Sunbird AI APIs.
To get started using the API, view the tutorial.
This is required because CPU virtualization is needed for Windows to emulate Linux. For more on enabling virtualization.
Install WSL (Windows Subsystem for Linux). This is required because redis is not officially supported on Windows.
- Open PowerShell as an Administrator and run the following command to enable WSL:
wsl --install
- Restart your computer if prompted.
- Once the system restarts, set up your Linux distribution (e.g., Ubuntu) from the Microsoft Store.
-
Press windows button and in the search bar type
windows features on or off
-
Click on
Turn Windows features on or off
and a pop-up window will appear -
Ensure option
Windows Subsystem for Linux
is checked -
Restart your computer and launch Ubuntu
-
Open your WSL terminal (e.g., Ubuntu).
-
Navigate to the directory where you want to clone the repository:
cd /mnt/c/your-directory
-
Clone the Sunbird AI API repository:
git clone https://github.com/SunbirdAI/sunbird-ai-api.git
-
Continue with
Getting started locally on Linux/macOS
To run the app locally:
-
Create and activate a local environment
python3 -m venv .venv source .venv/bin/activate
-
Install the requirements:
pip install -r requirements.txt
-
Set the environment variables in a
.env
file, the following variables are required:SECRET_KEY DATABASE_URL RUNPOD_API_KEY REDIS_URL RUNPOD_ENDPOINT AUDIO_CONTENT_BUCKET_NAME
NB: Reach out to the engineering team to get these environment variables.
Install Redis, this is required for the Rate Limiting functionality.
sudo apt update && sudo apt install redis-server
-
Start the Redis sever:
sudo service redis-server start
-
Verify that Redis is running:
redis-cli ping
-
Install PostgreSQL:
sudo apt-get install postgresql postgresql-contrib
-
Start the PostgreSQL service:
sudo service postgresql start
-
Switch to the PostgreSQL user:
sudo -i -u postgres
-
Open the PostgreSQL interactive terminal:
psql
Install tailwind css.
-
Run tailwind in a separate terminal tab:
npx tailwindcss -i ./app/static/input.css -o ./app/static/output.css --watch
This step is only necessary if you're going to make changes to the frontend code.
- Create a new database:
CREATE DATABASE sunbird_ai;
- Exit the PostgreSQL interactive terminal:
\q
- Navigate to the API repository directory and run Alembic migrations:
cd your-directory/sunbird-ai-api alembic upgrade head
- Run the app:
uvicorn app.api:app --reload
-
After making a change to the models, run the command below to make the migrations:
alembic revision --autogenerate -m 'message'
-
Check the created migration file in
app/alembic/versions
to ensure it does what's expected. -
Apply the migration with:
alembic upgrade head
The app is deployed on Google Cloud Run and is backed by PostgreSQL DB hosted in Google Cloud SQL.
- Checkout the System design document (you need to part of the Sunbird organization to view this).
- Checkout the Deployment Guide.