IN THIS LESSON
A comprehensive guide for setting up AiKit's AI-powered web application stack locally using Docker Compose.
Covers:
Environment configuration for AI providers (Replicate, OpenAI),
Service orchestration (PostgreSQL, MinIO, FastAPI backend, Next.js frontend),
File storage setup (local MinIO and production S3),
Authentication configuration (local and Supabase),
And common development workflows with Makefile commands. Includes troubleshooting guidance for common issues and debugging techniques.
Run Locally with AI Integrations
This guide covers how to run the AiKit application locally with AI integrations. It includes steps for setting up the environment, starting the application without Docker, and accessing the application.
Starting the application directly without Docker is useful for development and debugging purposes. The only dependency is a PostgreSQL database, which can be run using standalone Docker container or by installing PostgreSQL directly on your machine. We recommend using a dockerized PostgreSQL instance for simplicity. The Dev Kit includes a Makefile
with commands to help you run the application locally.
Apart from running the application, this guide also covers how to set up AI providers and file storage for local development.
Run Backend and Frontend Locally
Database Setup
The first step is to set up a PostgreSQL database. You can either install PostgreSQL directly on your machine or use Docker to run it.
For local development, you can use Docker for PostgreSQL.
To start the database service:
make db-only
This command will start a PostgreSQL database container using the configuration defined in the docker-compose.yml
file.
Backend Setup
- Navigate to the backend directory:
cd backend
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Run database migrations:
alembic upgrade head
- Start the FastAPI server:
uvicorn main:app --reload --port 8000
Frontend Setup
- Navigate to the frontend directory:
cd frontend
- Install dependencies:
npm install
- Start the development server:
npm run dev
Configuration
AI Provider Setup
Replicate
- Sign up at Replicate
- Get your API token from the dashboard
- Add it to your
.env
file asREPLICATE_API_TOKEN
OpenAI
- Sign up at OpenAI
- Get your API key from the dashboard
- Add it to your
.env
file asOPENAI_API_KEY
File Storage Setup
Local Development (MinIO)
MinIO is included in the Docker Compose setup. Access the console at http://localhost:9001 with credentials admin/password123
.
Production (AWS S3)
- Create an S3 bucket
- Create IAM credentials with S3 access
- Update the
.env
file with your AWS credentials
Authentication Setup
Local Development
The application includes a basic authentication system for local development.
Production (Supabase)
- Create a project at Supabase
- Get your project URL and API keys
- Update the
.env
file with your Supabase credentials
Development Workflow
Common Commands
Use the included Makefile for common tasks:
# Start only the database service
make db-only
# Show logs
make show-logs
# Stop the database service
make db-stop
Making Changes
- Backend changes: The FastAPI server will auto-reload when you save files
- Frontend changes: The Next.js development server will hot-reload
- Database changes: Create new Alembic migrations:
cd backend alembic revision --autogenerate -m "Description of changes" alembic upgrade head
Troubleshooting
Common Issues
Port already in use
# Find and kill the process using the port
lsof -ti:8000 | xargs kill -9
Database connection issues
# Check if PostgreSQL is running
docker ps | grep postgres
# Reset the database
docker-compose down -v
docker-compose up -d
Node modules issues
# Clean install
rm -rf node_modules package-lock.json
npm install
Python dependencies issues
# Recreate virtual environment
rm -rf venv
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt