Comp AI is an open-source compliance platform designed to help you achieve compliance with frameworks like SOC 2, ISO 27001, HIPAA, and GDPR. It automates evidence collection, policy management, and control implementation, giving you control over your data and infrastructure.
This guide provides step-by-step instructions to get Comp AI running on your local machine for development and testing. By following these steps, you'll have a fully functional local instance of the platform.
Before you begin, ensure you have the following software installed on your system:
- Node.js: Version
20.xor higher - Bun: Version
1.1.36or higher - PostgreSQL: Version
15.xor higher - Docker Desktop or Docker Engine (for database setup)
Get the Comp AI Codebase
First, you need to download the Comp AI project files to your local machine.
- Clone the repository:
git clone https://github.com/trycompai/comp.git - Navigate to the project directory:
cd comp
- Clone the repository:
Install Project Dependencies
Once you're in the project directory, install all necessary dependencies using Bun.
bun installPrepare Environment Variables
Comp AI uses environment variables to manage configurations and credentials. You'll need to create
.envfiles in specific locations and fill them with your settings.-
Copy example environment files: These commands create the necessary
.envfiles from their examples.cp apps/app/.env.example apps/app/.env cp apps/portal/.env.example apps/portal/.env cp packages/db/.env.example packages/db/.env -
Fill in required variables for
apps/app/.env: Open theapps/app/.envfile and add or update the following variables.AUTH_SECRET="" DATABASE_URL="postgresql://user:password@host:port/database" RESEND_API_KEY="" NEXT_PUBLIC_PORTAL_URL="http://localhost:3002" REVALIDATION_SECRET=""AUTH_SECRETandREVALIDATION_SECRET: Generate secure random strings for these. You can use a command likeopenssl rand -base64 32in your terminal.DATABASE_URL: This will be your PostgreSQL connection string. You'll configure the database in a later step.RESEND_API_KEY: Obtain this from your Resend account (https://resend.com/api-keys).
The
.env.examplefiles might not includeNEXT_PUBLIC_PORTAL_URLandREVALIDATION_SECRET. Ensure you add these manually to yourapps/app/.envfile.
-
Configure Cloud & Authentication Services
Comp AI integrates with several external services for authentication, workflows, and data storage. You'll need to set these up.
-
Trigger.dev (Workflows)
- Create an account at https://cloud.trigger.dev.
- Create a new project and copy its Project ID.
- Open the file
apps/app/trigger.config.tsand update theprojectfield with your Project ID:project: 'proj_****az***ywb**ob*'; // Replace with your actual Project ID
-
Google OAuth (Authentication)
- Go to the Google Cloud OAuth Console.
- Create a new OAuth client:
- Select "Web Application" as the application type.
- Give it a name, e.g.,
comp_app. - Add the following Authorized Redirect URIs:
http://localhost http://localhost:3000 http://localhost:3002 http://localhost:3000/api/auth/callback/google http://localhost:3002/api/auth/callback/google http://localhost:3000/auth http://localhost:3002/auth
- After creation, copy the
Client ID(yourGOOGLE_ID) andClient Secret(yourGOOGLE_SECRET). - Add these to your
.envfiles.
If Google OAuth variables are not recognized from your
.envfiles, you might need to hard-code them directly intoapps/portal/src/app/lib/auth.ts. -
Redis (Upstash for Key-Value Store)
- Go to https://console.upstash.com.
- Create a new Redis database.
- Copy the Redis URL and TOKEN.
- Add these to your
.envfile.
If Redis environment variables are not recognized, you might need to hard-code them into
packages/kv/src/index.ts.
-
Set up the Database
Comp AI uses PostgreSQL. You'll use Docker to run a local PostgreSQL instance and then apply the necessary schema and data.
-
Navigate to the database package:
cd packages/db -
Start the PostgreSQL database using Docker:
bun run docker:upThe default credentials for the database are:
- Database name:
comp - Username:
postgres - Password:
postgresYou can change the password by connecting to the database and runningALTER USER postgres WITH PASSWORD 'new_password';.
- Database name:
-
Generate Prisma client:
bun run db:generate -
Push the schema to the database:
bun run db:push -
Optionally, seed the database with initial data:
bun run db:seed -
Fix potential database function error: If you encounter an error like
HINT: No function matches the given name and argument types..., run the following command (replace<your_password>with your PostgreSQL password):psql "postgresql://postgres:<your_password>@localhost:5432/comp" -f ./prisma/functionDefinition.sqlExpected output:
CREATE FUNCTIONUseful Database Commands:
bun run db:studio: Open Prisma Studio to view and edit data.bun run db:migrate: Run database migrations.bun run docker:down: Stop the database container.bun run docker:clean: Remove the database container and its volume.
-
Start the Application
After all configurations are complete, you can start the Comp AI application.
-
Return to the root directory of the project:
cd ../.. -
Start all applications in parallel:
bun run devAlternatively, if you have Turbo installed, you can use:
turbo devIf you don't have Turbo installed, you can install it globally using Bun:
bun add -g turbo
🎉 Congratulations! You now have a working local instance of Comp AI!
-
Self-Hosting Comp AI
While this guide focuses on local development, Comp AI also supports self-hosting for production environments. This typically involves Docker-based deployments.
For detailed, up-to-date instructions on self-hosting, including environment variable references and Docker deployment steps, please refer to the official documentation: