Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
595225a
chore: remove lock files (bun.lock, yarn.lock)
0xdolan May 4, 2025
4ca3028
docs: update README with build and setup instructions
0xdolan May 4, 2025
7c98ac5
chore: update .env.example with required environment variables
0xdolan May 4, 2025
0e2d251
chore: remove yarn references and update package dependencies
0xdolan May 4, 2025
e97eff6
chore: update root package.json for consistency and dependency manage…
0xdolan May 4, 2025
1b1da17
chore: add bun.lock and yarn.lock to .gitignore
0xdolan May 4, 2025
0ba6f6f
chore(deps): bump node-fetch from 2.7.0 to 3.3.2
dependabot[bot] May 5, 2025
bddbcae
chore(deps): bump react-email from 3.0.4 to 4.0.11
dependabot[bot] May 5, 2025
5173aa0
feat: implement new organization welcome email sequence and remove le…
carhartlewis May 9, 2025
60730ea
Merge branch 'dependabot/npm_and_yarn/main/react-email-4.0.11' of git…
carhartlewis May 9, 2025
5c0f5b8
Merge branch 'dependabot/npm_and_yarn/main/node-fetch-3.3.2' of githu…
carhartlewis May 9, 2025
1208935
chore(deps): update nanoid from 5.1.0 to 5.1.5
carhartlewis May 9, 2025
96c5a96
refactor(email): update welcome email export path to marketing directory
carhartlewis May 9, 2025
db63ef3
Merge branch 'main' into fix/build-issues
carhartlewis May 9, 2025
3ae913e
refactor(email): correct comment from "Email templates" to "Email tem…
carhartlewis May 9, 2025
28d1964
refactor(email): update comment to pluralize "Email templates"
carhartlewis May 9, 2025
5ad0cf0
Merge pull request #522 from 0xdolan/fix/build-issues
carhartlewis May 9, 2025
ca7ea27
chore(deps): remove yarn.lock file
carhartlewis May 9, 2025
50b2c20
chore(prisma): remove unused preview feature from schema
carhartlewis May 9, 2025
5da82c6
Merge branch 'main' into lewis/comp-marketing-emails
carhartlewis May 9, 2025
4eb929d
Merge branch 'main' of github.com:trycompai/comp into lewis/comp-mark…
carhartlewis May 9, 2025
f3bb2c7
Merge branch 'lewis/comp-marketing-emails' of github.com:trycompai/co…
carhartlewis May 9, 2025
a0ec0ed
chore(prisma): update preview features in schema and adjust node-fetc…
carhartlewis May 9, 2025
3d64479
chore(deps): update dependencies for commitlint, turbo, AWS SDK, Reac…
carhartlewis May 9, 2025
7cf317e
Merge pull request #531 from trycompai/lewis/comp-marketing-emails
carhartlewis May 9, 2025
99ee59c
fix(package): add missing newline at end of file in package.json
carhartlewis May 9, 2025
e20f74c
Merge pull request #536 from trycompai/lewis/comp-fix
carhartlewis May 9, 2025
84dcf08
Merge branch 'release' into main
carhartlewis May 9, 2025
41d024d
fix(package): remove trailing newline in package.json
carhartlewis May 9, 2025
41d9288
Merge pull request #537 from trycompai/lewis/comp-fixes
carhartlewis May 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,7 @@ tailwind.css
# Playground (for local testing)
/playground
.venv

# Ignore lock files to prevent conflicts between different package managers
bun.lock
yarn.lock
308 changes: 260 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,90 +70,298 @@ Here is what you need to be able to run Comp AI.

## Development

To get the project working locally with all integrations, follow these extended development steps.

### Setup

1. Clone the repo into a public GitHub repository (or fork https://github.com/trycompai/comp/fork). If you modify and distribute the code, or run it as a network service, you must provide the source code to users under the terms of AGPLv3. For uses not covered by AGPLv3, a commercial license is available.
1. Clone the repo:

```sh
git clone https://github.com/trycompai/comp.git
```

2. Go to the project folder
2. Navigate to the project directory:

```sh
cd comp
```

3. Install packages with bun
3. Remove existing lock files:

#### Linux / macOS

```sh
rm bun.lock yarn.lock
```

#### Windows (Command Prompt)

```cmd
del bun.lock yarn.lock
```

#### Windows (PowerShell)

```powershell
Remove-Item bun.lock, yarn.lock
```

4. Remove any `yarn` references from `comp/apps/app/package.json`

```sh
"yarn": "^1.22.22",
```

> 💡 Make sure this line is already deleted or running `bun install` will give you an error.

5. Install dependencies using Bun:

```sh
bun install
```

6. Install `concurrently` as a dev dependency:

```sh
bun add -d concurrently
```

---

### Environment Setup

Create the following `.env` files and fill them out with your credentials:

- `comp/apps/app/.env`
- `comp/apps/portal/.env`
- `comp/packages/db/.env`

You can copy from the `.env.example` files:

### Linux / macOS

```sh
cp apps/app/.env.example apps/app/.env
cp apps/portal/.env.example apps/portal/.env
cp packages/db/.env.example packages/db/.env
```

### Windows (Command Prompt)

```cmd
copy apps\app\.env.example apps\app\.env
copy apps\portal\.env.example apps\portal\.env
copy packages\db\.env.example packages\db\.env
```

### Windows (PowerShell)

```powershell
Copy-Item apps\app\.env.example -Destination apps\app\.env
Copy-Item apps\portal\.env.example -Destination apps\portal\.env
Copy-Item packages\db\.env.example -Destination packages\db\.env
```

Additionally, ensure the following required environment variables are added to `.env` in `comp/apps/app/.env`:

```env
AUTH_SECRET="" # Use `openssl rand -base64 32` to generate
DATABASE_URL="postgresql://user:password@host:port/database"
RESEND_API_KEY="" # Resend (https://resend.com/api-keys) - Resend Dashboard -> API Keys
NEXT_PUBLIC_PORTAL_URL="http://localhost:3002"
REVALIDATION_SECRET="" # Use `openssl rand -base64 32` to generate
```

> ✅ Make sure you have all of these variables in your `.env` file.
> If you're copying from `.env.example`, it might be missing the last two (`NEXT_PUBLIC_PORTAL_URL` and `REVALIDATION_SECRET`), so be sure to add them manually.

Some environment variables may not load correctly from `.env` — in such cases, **hard-code** the values directly in the relevant files (see Hardcoding section below).

---

### Cloud & Auth Configuration

#### 1. Trigger.dev

- Create an account on [https://cloud.trigger.dev](https://cloud.trigger.dev)
- Create a project and copy the Project ID
- In `comp/apps/app/trigger.config.ts`, set:
```ts
project: "proj_****az***ywb**ob*";
```

#### 2. Google OAuth

- Go to [Google Cloud OAuth Console](https://console.cloud.google.com/auth/clients)
- Create an OAuth client:
- Type: Web Application
- Name: `comp_app` # You can choose a different name if you prefer!
- Add these **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 creating the app, copy the `GOOGLE_ID` and `GOOGLE_SECRET`
- Add them to your `.env` files
- If that doesn’t work, hard-code them in:
```
comp/apps/portal/src/app/lib/auth.ts
```

#### 3. Redis (Upstash)

- Go to [https://console.upstash.com](https://console.upstash.com)
- Create a Redis database
- Copy the **Redis URL** and **TOKEN**
- Add them to your `.env` file, or hard-code them if the environment variables are not being recognized in:
```
comp/packages/kv/src/index.ts
```

---

### Database Setup

Start and initialize the PostgreSQL database using Docker:

1. Start the database:

```sh
bun i
bun docker:up
```

4. Set up your `.env` files
- Copy the example environment files to create your local environment files:
```sh
cp apps/app/.env.example apps/app/.env
cp apps/portal/.env.example apps/portal/.env
2. Default credentials:

- Database name: `comp`
- Username: `postgres`
- Password: `postgres`

3. To change the default password:

```sql
ALTER USER postgres WITH PASSWORD 'new_password';
```
- Fill in the required environment variables in both `.env` files
- Use `openssl rand -base64 32` to generate a key and add it under `AUTH_SECRET` in the `apps/app/.env` file

5. Setup Node
If your Node version does not meet the project's requirements as instructed by the docs, "nvm" (Node Version Manager) allows using Node at the version required by the project:
4. If you encounter the following error:

```sh
nvm use
```
HINT: No function matches the given name and argument types...
```

You first might need to install the specific version and then use it:
Run the fix:

```sh
nvm install && nvm use
psql "postgresql://postgres:<your_password>@localhost:5432/comp" -f ./packages/db/prisma/functionDefinition.sql
```

You can install nvm from [here](https://github.com/nvm-sh/nvm).
Expected output: `CREATE FUNCTION`

6. Setup Database
Start the Postgres database using Docker:
> 💡 `comp` is the database name. Make sure to use the correct **port** and **database name** for your setup.

```sh
bun docker:up
```
5. Apply schema and seed:

Then set up the database schema and seed data:
```sh
# Generate Prisma client
bun db:generate

```sh
# Generate Prisma client
bun db:generate
# Push the schema to the database
bun db:push

# Push the schema to the database
bun db:push
# Optional: Seed the database with initial data
bun db:seed
```

# Optional: Seed the database with initial data
bun db:seed
```
Other useful database commands:

Other useful database commands:
```sh
# Open Prisma Studio to view/edit data
bun db:studio
```sh
# Open Prisma Studio to view/edit data
bun db:studio

# Run database migrations
bun db:migrate
# Run database migrations
bun db:migrate

# Stop the database container
bun docker:down
# Stop the database container
bun docker:down

# Remove the database container and volume
bun docker:clean
```
# Remove the database container and volume
bun docker:clean
```

7. Run the turbo dev command to start the development server
---

```sh
turbo dev
```
### Hardcoding Env Vars (if needed)

If `.env` files don’t load values as expected, you can hard-code the following:

- **`comp/packages/kv/src/index.ts`** → Hard-coded Redis client credentials:

- **URL**: The Redis URL needs to start with `https`. Example:
```sh
url: "https://default:AXhaAA***MA@charmed-wombat-3**0.upstash.io:6379"
```
- **Token**: Example:
```sh
token: "935****8f20"
```

- **`comp/packages/db/prisma/schema.prisma`** → Hard-coded `DATABASE_URL`:

- Example:
`sh
datasource db {
url = "postpostgresql://user:password@host:port/database?schema=public"
directUrl = "postpostgresql://user:password@host:port/database?schema=public"
}
`

- **`comp/apps/portal/src/app/lib/auth.ts`** → Hard-coded Google environment variables `clientId`, `clientSecret` under `socialProviders/google`:

- Example:
```js
socialProviders: {
google: {
clientId: "your-client-id",
clientSecret: "your-client-secret"
}
}
```

- **`comp/apps/app/trigger.config.ts`** → Change the project to yours:
- Example:
```sh
projectId: "proj_la**ob"
```

---

### Start Development

Once everything is configured:

```sh
bun run dev
```

Or use the Turbo repo script:

```sh
turbo dev
```

> 💡 Make sure you have Turbo installed. If not, you can install it using Bun:

```sh
bun add -g turbo
```

🎉 Yay! You now have a working local instance of Comp AI! 🚀

## Deployment

Expand Down Expand Up @@ -182,4 +390,8 @@ Steps to deploy Comp AI on Vercel are coming soon.
Comp AI, Inc. is a commercial open source company, which means some parts of this open source repository require a commercial license. The concept is called "Open Core" where the core technology (99%) is fully open source, licensed under [AGPLv3](https://opensource.org/license/agpl-v3) and the last 1% is covered under a commercial license (["/ee" Enterprise Edition"]).

> [!TIP]
> We work closely with the community and always invite feedback about what should be open and what is fine to be commercial. This list is not set and stone and we have moved things from commercial to open in the past. Please open a [discussion](https://github.com/trycompai/comp/discussions) if you feel like something is wrong.
> We work closely with the community and always invite feedback about what should be open and what is fine to be commercial. This list is not set and stone and we have moved things from commercial to open in the past. Please open a [discussion](https://github.com/trycompai/comp/discussions) if you feel like something is wrong.

```

```
Loading
Loading