Skip to content

Commit e03f5de

Browse files
[dev] [Marfuen] mariano/automation-resolver (#1681)
* feat(automation): add evaluation criteria and status to automations * feat(automation): update button styles based on test state * chore(hooks): enable revalidation on focus and add deduping interval * refactor(automation): redesign TestResultsPanel layout and enhance functionality * refactor(automation): update TestResultsPanel with new button and layout enhancements * refactor(automation): add fail state icon and update test completion message * refactor(docs): update README with detailed setup instructions and env variables * fix(tasks): add 'failed' status to task statuses and update indicators * chore(db): update @trycompai/db package version to 1.3.15 * refactor(types): replace inline types with Policy and Task interfaces --------- Co-authored-by: Mariano Fuentes <marfuen98@gmail.com>
1 parent 2a7be98 commit e03f5de

File tree

37 files changed

+1255
-446
lines changed

37 files changed

+1255
-446
lines changed

README.md

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,39 +81,68 @@ Here is what you need to be able to run Comp AI.
8181

8282
## Development
8383

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

8686
### Setup
8787

88-
1. Clone the repo:
88+
## Add environment variables and fill them out with your credentials
8989

90-
```sh
91-
git clone https://github.com/trycompai/comp.git
92-
```
90+
```sh
91+
cp apps/app/.env.example apps/app/.env
92+
cp apps/portal/.env.example apps/portal/.env
93+
cp packages/db/.env.example packages/db/.env
94+
```
9395

94-
2. Navigate to the project directory:
96+
## Get code running locally
9597

96-
```sh
97-
cd comp
98-
```
98+
1. Clone the repo
99+
100+
```sh
101+
git clone https://github.com/trycompai/comp.git
102+
```
99103

100-
3. Install dependencies using Bun:
104+
2. Navigate to the project directory
101105

102106
```sh
103-
bun install
107+
cd comp
104108
```
105109

106-
4. Install `concurrently` as a dev dependency:
110+
3. Install dependencies using Bun
107111

108112
```sh
109-
bun add -d concurrently
113+
bun install
114+
```
115+
116+
4. Get Database Running
117+
118+
```sh
119+
cd packages/db
120+
bun run docker:up # Spin up docker container
121+
bun run db:migrate # Run migrations
122+
```
123+
124+
5. Generate Prisma Types for each app
125+
126+
```sh
127+
cd apps/app
128+
bun run db:generate
129+
cd ../portal
130+
bun run db:generate
131+
cd ../api
132+
bun run db:generate
133+
```
134+
135+
6. Run all apps in parallel from the root directory
136+
137+
```sh
138+
bun run dev
110139
```
111140

112141
---
113142

114143
### Environment Setup
115144

116-
Create the following `.env` files and fill them out with your credentials:
145+
Create the following `.env` files and fill them out with your credentials
117146

118147
- `comp/apps/app/.env`
119148
- `comp/apps/portal/.env`

apps/app/.env.example

Lines changed: 53 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,54 @@
1-
# Required
2-
AUTH_SECRET="" # openssl rand -base64 32
3-
DATABASE_URL="" # Format: "postgresql://postgres:pass@127.0.0.1:5432/comp"
4-
RESEND_DOMAIN=" # Domain configured in Resend, e.g. mail.trycomp.ai
5-
RESEND_API_KEY="" # API key from Resend for email authentication / invites
6-
REVALIDATION_SECRET="" # openssl rand -base64 32
7-
NEXT_PUBLIC_PORTAL_URL="http://localhost:3002" # The employee portal uses port 3002 by default
8-
9-
# Recommended
10-
# Store attachments in any S3 compatible bucket, we use AWS
11-
APP_AWS_ACCESS_KEY_ID="" # AWS Access Key ID
12-
APP_AWS_SECRET_ACCESS_KEY="" # AWS Secret Access Key
13-
APP_AWS_REGION="" # AWS Region
14-
APP_AWS_BUCKET_NAME="" # AWS Bucket Name
15-
16-
TRIGGER_SECRET_KEY="" # For background jobs. Self-host or use cloud-version @ https://trigger.dev
17-
# TRIGGER_API_URL="" # Only set if you are self-hosting
18-
TRIGGER_API_KEY="" # API key from Trigger.dev
19-
TRIGGER_SECRET_KEY="" # Secret key from Trigger.dev
20-
21-
OPENAI_API_KEY="" # AI Chat + Auto Generated Policies, Risks + Vendors
22-
FIRECRAWL_API_KEY="" # For research, self-host or use cloud-version @ https://firecrawl.dev
1+
# Authentication & Database
232

3+
AUTH_GOOGLE_ID="" # Google login
4+
AUTH_GOOGLE_SECRET="" # Google Login
5+
AUTH_GITHUB_ID="" # Optional
6+
AUTH_GITHUB_SECRET="" # Optional
7+
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/comp" # Should be the default
8+
AUTH_SECRET="" # Used for auth, use something random and strong
9+
SECRET_KEY="" # Used for encrypting data, use something random and strong
10+
NEXT_PUBLIC_BETTER_AUTH_URL=http://localhost:3000 # Must point to the domain hosting the app
11+
12+
# Upstash
13+
UPSTASH_REDIS_REST_URL="" # Optional, used for rate limiting
14+
UPSTASH_REDIS_REST_TOKEN="" # Optional, used for rate limiting
15+
16+
# OpenAI
17+
OPENAI_API_KEY="" # Required for app to work
18+
19+
# Resend
20+
RESEND_API_KEY="" # For sending emails, app notifications, etc.
21+
22+
# Trigger
23+
TRIGGER_SECRET_KEY="" # Required, for all async jobs and tasks
24+
25+
# Posthog
26+
NEXT_PUBLIC_POSTHOG_HOST=/ingest # GTM Trackers
27+
NEXT_PUBLIC_POSTHOG_KEY="" # GTM Trackers
28+
29+
# Vercel
30+
VERCEL_ACCESS_TOKEN="" # For trust portal domains
31+
VERCEL_TEAM_ID="" # For trust portal domains
32+
VERCEL_PROJECT_ID="" # For trust portal domains
33+
NEXT_PUBLIC_VERCEL_URL="" # eg. trycomp.ai
34+
35+
# AWS
36+
APP_AWS_BUCKET_NAME="" # Required, for task attachments
37+
APP_AWS_REGION="" # Required, for task attachments
38+
APP_AWS_ACCESS_KEY_ID="" # Required, for task attachments
39+
APP_AWS_SECRET_ACCESS_KEY="" # Required, for task attachments
40+
41+
# TRIGGER REVAL
42+
REVALIDATION_SECRET="" # Revalidate server side, generate something random
43+
44+
GROQ_API_KEY="" # For the AI chat, on dashboard
45+
NEXT_PUBLIC_PORTAL_URL="http://localhost:3001"
46+
ANTHROPIC_API_KEY="" # Optional, For more options with models
47+
BETTER_AUTH_URL=http://localhost:3000 # For auth
48+
49+
NEXT_OUTPUT_STANDALONE=false # For deploying on AWS instead of Vercel
50+
51+
FLEET_URL="" # If you want to enable MDM, your hosted url
52+
FLEET_TOKEN="" # If you want to enable MDM
53+
54+
FIRECRAWL_API_KEY="" # To research vendors, Required

apps/app/src/app/(app)/[orgId]/frameworks/components/Overview.tsx

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22

3-
import { FrameworkEditorFramework } from '@db';
3+
import { FrameworkEditorFramework, Policy, Task } from '@db';
44
import { FrameworkInstanceWithControls } from '../types';
55
import { ComplianceOverview } from './ComplianceOverview';
66
import { DraggableCards } from './DraggableCards';
@@ -11,31 +11,15 @@ import { FrameworkInstanceWithComplianceScore } from './types';
1111
export interface PublishedPoliciesScore {
1212
totalPolicies: number;
1313
publishedPolicies: number;
14-
draftPolicies: {
15-
id: string;
16-
status: 'draft' | 'published' | 'needs_review';
17-
name: string;
18-
}[];
19-
policiesInReview: {
20-
id: string;
21-
status: 'draft' | 'published' | 'needs_review';
22-
name: string;
23-
}[];
24-
unpublishedPolicies: {
25-
id: string;
26-
status: 'draft' | 'published' | 'needs_review';
27-
name: string;
28-
}[];
14+
draftPolicies: Policy[];
15+
policiesInReview: Policy[];
16+
unpublishedPolicies: Policy[];
2917
}
3018

3119
export interface DoneTasksScore {
3220
totalTasks: number;
3321
doneTasks: number;
34-
incompleteTasks: {
35-
id: string;
36-
title: string;
37-
status: 'todo' | 'in_progress' | 'done' | 'not_relevant';
38-
}[];
22+
incompleteTasks: Task[];
3923
}
4024

4125
export interface OverviewProps {

apps/app/src/app/(app)/[orgId]/frameworks/components/ToDoOverview.tsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Button } from '@comp/ui/button';
55
import { Card, CardContent, CardHeader, CardTitle } from '@comp/ui/card';
66
import { ScrollArea } from '@comp/ui/scroll-area';
77
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@comp/ui/tabs';
8+
import { Policy, Task } from '@db';
89
import {
910
ArrowRight,
1011
CheckCircle2,
@@ -20,18 +21,6 @@ import { useMemo, useState } from 'react';
2021
import { toast } from 'sonner';
2122
import { ConfirmActionDialog } from './ConfirmActionDialog';
2223

23-
interface Policy {
24-
id: string;
25-
name: string;
26-
status: 'draft' | 'published' | 'needs_review';
27-
}
28-
29-
interface Task {
30-
id: string;
31-
title: string;
32-
status: 'todo' | 'in_progress' | 'done' | 'not_relevant';
33-
}
34-
3524
export function ToDoOverview({
3625
totalPolicies,
3726
totalTasks,

apps/app/src/app/(app)/[orgId]/frameworks/lib/getPolicies.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ export async function getPublishedPoliciesScore(organizationId: string) {
55
where: {
66
organizationId,
77
},
8-
select: {
9-
id: true,
10-
name: true,
11-
status: true,
12-
},
138
});
149

1510
const publishedPolicies = allPolicies.filter((p) => p.status === 'published');

apps/app/src/app/(app)/[orgId]/frameworks/lib/getTasks.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ export const getDoneTasks = cache(async (organizationId: string) => {
66
where: {
77
organizationId,
88
},
9-
select: {
10-
id: true,
11-
title: true,
12-
status: true,
13-
},
149
});
1510

1611
const doneTasks = tasks.filter((t) => t.status === 'done');

0 commit comments

Comments
 (0)