-
Notifications
You must be signed in to change notification settings - Fork 0
[1a] Project scaffolding + core schema #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b7abd1f
feat: project scaffolding and core schema
cursoragent d7f686e
fix(ci): remove explicit pnpm version to use packageManager field
cursoragent 8be4418
feat(db): add unique partial index for one primary department per user
cursoragent e1e8e1d
refactor(api): use shared MCPRequest type instead of local interface
cursoragent 0eb4169
chore: update lockfile for @cortex/shared dependency
cursoragent ba18bae
fix(shared): export TypeScript source directly for internal package p…
cursoragent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| lint-and-typecheck: | ||
| name: Lint & Type Check | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22' | ||
| cache: 'pnpm' | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Generate Prisma client | ||
| run: pnpm --filter db db:generate | ||
| env: | ||
| DATABASE_URL: "postgresql://localhost:5432/test" | ||
|
|
||
| - name: Type check | ||
| run: pnpm check-types | ||
|
|
||
| - name: Lint | ||
| run: pnpm lint | ||
|
|
||
| - name: Format check | ||
| run: pnpm format --check | ||
|
|
||
| build: | ||
| name: Build | ||
| runs-on: ubuntu-latest | ||
| needs: lint-and-typecheck | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22' | ||
| cache: 'pnpm' | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Generate Prisma client | ||
| run: pnpm --filter db db:generate | ||
| env: | ||
| DATABASE_URL: "postgresql://localhost:5432/test" | ||
|
|
||
| - name: Build | ||
| run: pnpm build | ||
|
|
||
| validate-schema: | ||
| name: Validate Prisma Schema | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22' | ||
| cache: 'pnpm' | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Validate Prisma schema | ||
| run: pnpm --filter db db:validate | ||
| env: | ||
| DATABASE_URL: "postgresql://localhost:5432/test" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Dependencies | ||
| node_modules/ | ||
| pnpm-lock.yaml | ||
|
|
||
| # Build outputs | ||
| dist/ | ||
| .next/ | ||
| out/ | ||
|
|
||
| # Generated files | ||
| packages/db/generated/ | ||
|
|
||
| # Package manager | ||
| .pnpm-store/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,159 +1,122 @@ | ||
| # Turborepo starter | ||
| # Cortex | ||
|
|
||
| This Turborepo starter is maintained by the Turborepo core team. | ||
| A TypeScript monorepo for an MCP-first context, policy, and audit platform. | ||
|
|
||
| ## Using this example | ||
| ## Getting Started | ||
|
|
||
| Run the following command: | ||
| ### Prerequisites | ||
|
|
||
| ```sh | ||
| npx create-turbo@latest | ||
| ``` | ||
|
|
||
| ## What's inside? | ||
|
|
||
| This Turborepo includes the following packages/apps: | ||
|
|
||
| ### Apps and Packages | ||
|
|
||
| - `docs`: a [Next.js](https://nextjs.org/) app | ||
| - `web`: another [Next.js](https://nextjs.org/) app | ||
| - `@repo/ui`: a stub React component library shared by both `web` and `docs` applications | ||
| - `@repo/eslint-config`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`) | ||
| - `@repo/typescript-config`: `tsconfig.json`s used throughout the monorepo | ||
|
|
||
| Each package/app is 100% [TypeScript](https://www.typescriptlang.org/). | ||
|
|
||
| ### Utilities | ||
| - Node.js >= 18 | ||
| - pnpm 9.x | ||
| - Docker (for local development with PostgreSQL and Redis) | ||
|
|
||
| This Turborepo has some additional tools already setup for you: | ||
|
|
||
| - [TypeScript](https://www.typescriptlang.org/) for static type checking | ||
| - [ESLint](https://eslint.org/) for code linting | ||
| - [Prettier](https://prettier.io) for code formatting | ||
|
|
||
| ### Build | ||
|
|
||
| To build all apps and packages, run the following command: | ||
|
|
||
| With [global `turbo`](https://turborepo.dev/docs/getting-started/installation#global-installation) installed (recommended): | ||
| ### Installation | ||
|
|
||
| ```sh | ||
| cd my-turborepo | ||
| turbo build | ||
| ``` | ||
|
|
||
| Without global `turbo`, use your package manager: | ||
| # Install dependencies | ||
| pnpm install | ||
|
|
||
| ```sh | ||
| cd my-turborepo | ||
| npx turbo build | ||
| pnpm dlx turbo build | ||
| pnpm exec turbo build | ||
| # Generate Prisma client (requires DATABASE_URL) | ||
| DATABASE_URL="postgresql://cortex:cortex@localhost:5432/cortex" pnpm --filter db db:generate | ||
| ``` | ||
|
|
||
| You can build a specific package by using a [filter](https://turborepo.dev/docs/crafting-your-repository/running-tasks#using-filters): | ||
| ### Development | ||
|
|
||
| With [global `turbo`](https://turborepo.dev/docs/getting-started/installation#global-installation) installed: | ||
| Start the development environment: | ||
|
|
||
| ```sh | ||
| turbo build --filter=docs | ||
| ``` | ||
| # Start PostgreSQL and Redis | ||
| docker-compose up -d | ||
|
|
||
| Without global `turbo`: | ||
|
|
||
| ```sh | ||
| npx turbo build --filter=docs | ||
| pnpm exec turbo build --filter=docs | ||
| pnpm exec turbo build --filter=docs | ||
| # Run all apps in development mode | ||
| pnpm dev | ||
| ``` | ||
|
|
||
| ### Develop | ||
| ## Project Structure | ||
|
|
||
| To develop all apps and packages, run the following command: | ||
| ### Apps | ||
|
|
||
| With [global `turbo`](https://turborepo.dev/docs/getting-started/installation#global-installation) installed (recommended): | ||
| - `apps/web` - Admin Web (Next.js) | ||
| - `apps/docs` - Documentation site (Next.js) | ||
| - `apps/api` - API + MCP entrypoint (NestJS) | ||
|
|
||
| ```sh | ||
| cd my-turborepo | ||
| turbo dev | ||
| ``` | ||
| ### Packages | ||
|
|
||
| Without global `turbo`, use your package manager: | ||
| - `packages/db` - Prisma schema and database client | ||
| - `packages/ui` - Shared React component library (`@cortex/ui`) | ||
| - `packages/shared` - Shared types and utilities (`@cortex/shared`) | ||
| - `packages/eslint-config` - ESLint configurations (`@cortex/eslint-config`) | ||
| - `packages/typescript-config` - TypeScript configurations (`@cortex/typescript-config`) | ||
|
|
||
| ## Commands | ||
|
|
||
| ```sh | ||
| cd my-turborepo | ||
| npx turbo dev | ||
| pnpm exec turbo dev | ||
| pnpm exec turbo dev | ||
| ``` | ||
| # Install dependencies | ||
| pnpm install | ||
|
|
||
| You can develop a specific package by using a [filter](https://turborepo.dev/docs/crafting-your-repository/running-tasks#using-filters): | ||
| # Build all workspaces | ||
| pnpm build | ||
|
|
||
| With [global `turbo`](https://turborepo.dev/docs/getting-started/installation#global-installation) installed: | ||
| # Type-check all workspaces | ||
| pnpm check-types | ||
|
|
||
| ```sh | ||
| turbo dev --filter=web | ||
| ``` | ||
| # Lint all workspaces | ||
| pnpm lint | ||
|
|
||
| Without global `turbo`: | ||
| # Format code | ||
| pnpm format | ||
|
|
||
| ```sh | ||
| npx turbo dev --filter=web | ||
| pnpm exec turbo dev --filter=web | ||
| pnpm exec turbo dev --filter=web | ||
| # Run dev servers | ||
| pnpm dev | ||
| ``` | ||
|
|
||
| ### Remote Caching | ||
|
|
||
| > [!TIP] | ||
| > Vercel Remote Cache is free for all plans. Get started today at [vercel.com](https://vercel.com/signup?utm_source=remote-cache-sdk&utm_campaign=free_remote_cache). | ||
| ### Database Commands | ||
|
|
||
| Turborepo can use a technique known as [Remote Caching](https://turborepo.dev/docs/core-concepts/remote-caching) to share cache artifacts across machines, enabling you to share build caches with your team and CI/CD pipelines. | ||
| ```sh | ||
| # Generate Prisma client | ||
| pnpm --filter db db:generate | ||
|
|
||
| By default, Turborepo will cache locally. To enable Remote Caching you will need an account with Vercel. If you don't have an account you can [create one](https://vercel.com/signup?utm_source=turborepo-examples), then enter the following commands: | ||
| # Validate Prisma schema | ||
| pnpm --filter db db:validate | ||
|
|
||
| With [global `turbo`](https://turborepo.dev/docs/getting-started/installation#global-installation) installed (recommended): | ||
| # Create a new migration | ||
| pnpm --filter db db:migrate | ||
|
|
||
| ```sh | ||
| cd my-turborepo | ||
| turbo login | ||
| # Apply pending migrations (production) | ||
| pnpm --filter db db:migrate:deploy | ||
| ``` | ||
|
|
||
| Without global `turbo`, use your package manager: | ||
| ## Docker Services | ||
|
|
||
| ```sh | ||
| cd my-turborepo | ||
| npx turbo login | ||
| pnpm exec turbo login | ||
| pnpm exec turbo login | ||
| ``` | ||
| The `docker-compose.yml` provides: | ||
|
|
||
| This will authenticate the Turborepo CLI with your [Vercel account](https://vercel.com/docs/concepts/personal-accounts/overview). | ||
| - **PostgreSQL 16** - Available at `localhost:5432` (user: `cortex`, password: `cortex`, database: `cortex`) | ||
| - **Redis 7** - Available at `localhost:6379` | ||
|
|
||
| Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your Turborepo: | ||
|
|
||
| With [global `turbo`](https://turborepo.dev/docs/getting-started/installation#global-installation) installed: | ||
| Start services: | ||
|
|
||
| ```sh | ||
| turbo link | ||
| docker-compose up -d | ||
| ``` | ||
|
|
||
| Without global `turbo`: | ||
| Stop services: | ||
|
|
||
| ```sh | ||
| npx turbo link | ||
| pnpm exec turbo link | ||
| pnpm exec turbo link | ||
| docker-compose down | ||
| ``` | ||
|
|
||
| ## Useful Links | ||
| ## Tech Stack | ||
|
|
||
| - **Package Manager**: pnpm (workspace monorepo) | ||
| - **Task Runner**: Turborepo | ||
| - **Language**: TypeScript | ||
| - **Web Framework**: Next.js 16 | ||
| - **API Framework**: NestJS | ||
| - **Database**: PostgreSQL with Prisma ORM | ||
| - **Cache**: Redis | ||
| - **Linting**: ESLint | ||
| - **Formatting**: Prettier | ||
|
|
||
| Learn more about the power of Turborepo: | ||
| ## License | ||
|
|
||
| - [Tasks](https://turborepo.dev/docs/crafting-your-repository/running-tasks) | ||
| - [Caching](https://turborepo.dev/docs/crafting-your-repository/caching) | ||
| - [Remote Caching](https://turborepo.dev/docs/core-concepts/remote-caching) | ||
| - [Filtering](https://turborepo.dev/docs/crafting-your-repository/running-tasks#using-filters) | ||
| - [Configuration Options](https://turborepo.dev/docs/reference/configuration) | ||
| - [CLI Usage](https://turborepo.dev/docs/reference/command-line-reference) | ||
| ISC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| import { config as baseConfig } from "@cortex/eslint-config/base"; | ||
|
|
||
| /** @type {import("eslint").Linter.Config[]} */ | ||
| export default baseConfig; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a PostgreSQL service for proper Prisma validation.
The workflow sets
DATABASE_URLtopostgresql://localhost:5432/test, but there's no PostgreSQL service configured. Whileprisma generateand basicprisma validatecan work without a live database, using a proper PostgreSQL service ensures:docker-compose.yml)🐘 Add PostgreSQL service to each job
Add this
servicesblock to each job that needs database access:Then update the DATABASE_URL to match:
Also applies to: 67-70, 94-97
🤖 Prompt for AI Agents