Skip to content

Commit 15f62ca

Browse files
github-actions[bot]tofikwestMarfuen
authored
[dev] [tofikwest] tofik/move-logic-from-SSA-to-API (#1853)
* refactor(api): move logic from SSE to API * chore(api): add knowledge base document management endpoints and refactor document actions * refactor(soa): moved SOA feature to API * feat(trust-portal): add compliance resource management endpoints and update documentation * refactor(questionnaire): remove unused actions for answering questions * refactor(questionnaire): clear questionnaire module * refactor(soa): enhance SOA service with new utility methods and improve answer processing * refactor(knowledge-base): clear components * refactor(vector-store-sync): restructure sync logic for policies, contexts, and knowledge base documents * refactor(knowledge-base): remove unused components and update document formats * refactor(api): remove duplicate DevicesModule import * refactor(api): rename compliance framework and update related logic * refactor(ci): remove Vercel credentials from deployment workflows * refactor(api): update compliance framework references to use TrustFramework * refactor(api): enhance SSE handling and add sanitization utilities * refactor(api): update SSE utilities to enhance security and sanitization --------- Co-authored-by: Tofik Hasanov <[email protected]> Co-authored-by: Mariano Fuentes <[email protected]>
1 parent 0192e34 commit 15f62ca

File tree

170 files changed

+13660
-7594
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+13660
-7594
lines changed

.env.example

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ AUTH_SECRET="" # openssl rand -base64 32
33
DATABASE_URL="" # Format: "postgresql://postgres:[email protected]:5432/comp"
44
RESEND_DOMAIN="" # Domain configured in Resend, e.g. mail.trycomp.ai
55
RESEND_API_KEY="" # API key from Resend for email authentication / invites
6-
RESEND_FROM_MARKETING="Lewis Carhart <[email protected]>"
7-
RESEND_FROM_SYSTEM="Comp AI <[email protected]>"
8-
RESEND_FROM_DEFAULT="Comp AI <[email protected]>"
9-
RESEND_TO_TEST="[email protected]"
10-
RESEND_REPLY_TO_MARKETING="[email protected]"
6+
RESEND_FROM_MARKETING=""
7+
RESEND_FROM_SYSTEM=""
8+
RESEND_FROM_DEFAULT=""
9+
RESEND_TO_TEST=""
10+
RESEND_REPLY_TO_MARKETING=""
1111
REVALIDATION_SECRET="" # openssl rand -base64 32
1212
NEXT_PUBLIC_PORTAL_URL="http://localhost:3002" # The employee portal uses port 3002 by default
1313

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Deploy API to Trigger.dev (dev)
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
deploy:
12+
runs-on: warp-ubuntu-latest-arm64-4x
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Use Node.js 20.x
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: "22.x" # Updated to match Node.js w/ Vercel
19+
- name: Setup Bun
20+
uses: oven-sh/setup-bun@v2
21+
- name: Clear cache
22+
run: rm -rf node_modules .bun
23+
- name: Install dependencies
24+
run: bun install --frozen-lockfile || bun install --frozen-lockfile --ignore-scripts
25+
- name: Install DB package dependencies
26+
working-directory: ./packages/db
27+
run: bun install --frozen-lockfile --ignore-scripts
28+
- name: Build DB package
29+
working-directory: ./packages/db
30+
run: bun run build
31+
- name: Copy schema to api and generate client
32+
working-directory: ./apps/api
33+
run: |
34+
mkdir -p prisma
35+
cp ../../packages/db/dist/schema.prisma prisma/schema.prisma
36+
bunx prisma generate
37+
- name: 🚀 Deploy Trigger.dev
38+
working-directory: ./apps/api
39+
timeout-minutes: 20
40+
env:
41+
TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }}
42+
run: bunx [email protected] deploy --env staging --log-level debug
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Deploy API to Trigger.dev (prod)
2+
3+
on:
4+
push:
5+
branches:
6+
- release
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
deploy:
13+
runs-on: warp-ubuntu-latest-arm64-4x
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Use Node.js 20.x
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: "20.x"
21+
22+
- name: Setup Bun
23+
uses: oven-sh/setup-bun@v2
24+
25+
- name: Install dependencies
26+
run: bun install --frozen-lockfile || bun install --frozen-lockfile --ignore-scripts
27+
- name: Install DB package dependencies
28+
working-directory: ./packages/db
29+
run: bun install --frozen-lockfile --ignore-scripts
30+
31+
- name: Build DB package
32+
working-directory: ./packages/db
33+
run: bun run build
34+
35+
- name: Copy schema to api and generate client
36+
working-directory: ./apps/api
37+
run: |
38+
mkdir -p prisma
39+
cp ../../packages/db/dist/schema.prisma prisma/schema.prisma
40+
bunx prisma generate
41+
42+
- name: 🚀 Deploy Trigger.dev
43+
working-directory: ./apps/api
44+
env:
45+
TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }}
46+
run: bunx [email protected] deploy

SELF_HOSTING.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ App (`apps/app`):
4646
- **APP_AWS_REGION**, **APP_AWS_ACCESS_KEY_ID**, **APP_AWS_SECRET_ACCESS_KEY**, **APP_AWS_BUCKET_NAME**: AWS S3 credentials for file storage (attachments, general uploads).
4747
- **APP_AWS_QUESTIONNAIRE_UPLOAD_BUCKET**: AWS S3 bucket name specifically for questionnaire file uploads. Required for the Security Questionnaire feature. If not set, users will see an error when trying to parse questionnaires.
4848
- **APP_AWS_KNOWLEDGE_BASE_BUCKET**: AWS S3 bucket name specifically for knowledge base documents. Required for the Knowledge Base feature in Security Questionnaire. If not set, users will see an error when trying to upload knowledge base documents.
49-
- **APP_AWS_ORG_ASSETS_BUCKET**: AWS S3 bucket name for organization static assets (e.g., company logos). Required for logo uploads in organization settings. If not set, logo upload will fail.
49+
- **APP_AWS_ORG_ASSETS_BUCKET**: AWS S3 bucket name for organization static assets (e.g., company logos, compliance certificates). Required for logo uploads in organization settings and Trust Portal compliance certificate uploads. If not set, these features will fail.
5050
- **OPENAI_API_KEY**: Enables AI features that call OpenAI models.
5151
- **UPSTASH_REDIS_REST_URL**, **UPSTASH_REDIS_REST_TOKEN**: Optional Redis (Upstash) used for rate limiting/queues/caching.
5252
- **NEXT_PUBLIC_POSTHOG_KEY**, **NEXT_PUBLIC_POSTHOG_HOST**: Client analytics via PostHog; leave unset to disable.
@@ -59,6 +59,17 @@ App (`apps/app`):
5959
- **GA4_API_SECRET**, **GA4_MEASUREMENT_ID**: Google Analytics 4 server/client tracking.
6060
- **NEXT_PUBLIC_API_URL**: Override client API base URL (defaults to same origin).
6161

62+
API (`apps/api`):
63+
64+
- **APP_AWS_REGION**, **APP_AWS_ACCESS_KEY_ID**, **APP_AWS_SECRET_ACCESS_KEY**, **APP_AWS_BUCKET_NAME**: AWS S3 credentials for file storage (attachments, general uploads).
65+
- **APP_AWS_QUESTIONNAIRE_UPLOAD_BUCKET**: AWS S3 bucket name specifically for questionnaire file uploads. Required for the Security Questionnaire feature.
66+
- **APP_AWS_KNOWLEDGE_BASE_BUCKET**: AWS S3 bucket name specifically for knowledge base documents. Required for the Knowledge Base feature in Security Questionnaire.
67+
- **APP_AWS_ORG_ASSETS_BUCKET**: AWS S3 bucket name for organization static assets (e.g., company logos, compliance certificates). Required for Trust Portal compliance certificate uploads and organization logo uploads. If not set, these features will fail.
68+
- **OPENAI_API_KEY**: Enables AI features that call OpenAI models.
69+
- **UPSTASH_VECTOR_REST_URL**, **UPSTASH_VECTOR_REST_TOKEN**: Required for vector database operations (questionnaire auto-answer, SOA auto-fill, knowledge base search).
70+
- **BETTER_AUTH_URL**: URL of the Better Auth instance (usually the same as the app URL).
71+
- **DATABASE_URL**: PostgreSQL database connection string.
72+
6273
Portal (`apps/portal`):
6374

6475
- **NEXT_PUBLIC_POSTHOG_KEY**, **NEXT_PUBLIC_POSTHOG_HOST**: Client analytics via PostHog for portal.

apps/api/.env.example

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
BASE_URL="http://localhost:3333"
2+
BETTER_AUTH_URL="http://localhost:3000"
3+
PORT="3333"
4+
5+
APP_AWS_BUCKET_NAME=
6+
APP_AWS_QUESTIONNAIRE_UPLOAD_BUCKET=
7+
APP_AWS_KNOWLEDGE_BASE_BUCKET=
8+
APP_AWS_REGION=
9+
APP_AWS_ACCESS_KEY_ID=
10+
APP_AWS_SECRET_ACCESS_KEY=
11+
APP_AWS_ORG_ASSETS_BUCKET=
12+
13+
DATABASE_URL=
14+
15+
16+
# Upstash
17+
UPSTASH_REDIS_REST_URL=
18+
UPSTASH_REDIS_REST_TOKEN=
19+
20+
UPSTASH_VECTOR_REST_URL=
21+
UPSTASH_VECTOR_REST_TOKEN=
22+
23+
# Trigger
24+
TRIGGER_SECRET_KEY=
25+
26+
OPENAI_API_KEY=

0 commit comments

Comments
 (0)