# Project

**Kind:** Database Model

**Source:** [`atloria-monorepo/libs/database/prisma/schema.prisma`](https://github.com/sherkety/atloria/blob/main/atloria-monorepo/libs/database/prisma/schema.prisma#L198)

`Project` represents a repository-backed project owned by an organization. It stores project identity, repository connection details, theme selection, and flexible JSON settings used to configure project-specific behavior.

## Fields

| Field | Type | Required | Key |
|---|---|---|---|
| `id` | `String` | ✓ | PK |
| `name` | `String` | ✓ |  |
| `slug` | `String` | ✓ |  |
| `description` | `String` | - |  |
| `organizationId` | `String` | ✓ |  |
| `themeId` | `String` | - |  |
| `repoUrl` | `String` | - |  |
| `repoBranch` | `String` | ✓ |  |
| `settings` | `Json` | - |  |
| `createdAt` | `DateTime` | ✓ |  |
| `updatedAt` | `DateTime` | ✓ |  |
| `isPublic` | `Boolean` | ✓ |  |
| `publishedAt` | `DateTime` | - |  |
| `urlId` | `String` | - | unique |
| `publishedSlug` | `String` | - |  |
| `toursEnabled` | `Boolean` | ✓ |  |
| `categories` | `Category[]` | ✓ |  |
| `documents` | `Document[]` | ✓ |  |
| `flows` | `Flow[]` | ✓ |  |
| `kgEntities` | `KGEntity[]` | ✓ |  |
| `members` | `ProjectMember[]` | ✓ |  |
| `screenshotJobs` | `ScreenshotJob[]` | ✓ |  |
| `screenshots` | `Screenshot[]` | ✓ |  |
| `autoDocConfig` | `ProjectAutoDocConfig` | - |  |
| `technicalSnapshot` | `TechnicalSnapshot` | - |  |
| `technicalStaleEntities` | `TechnicalStaleEntity[]` | ✓ |  |
| `docsPrConfig` | `DocsPrConfig` | - |  |
| `docsPullRequests` | `DocsPullRequest[]` | ✓ |  |
| `docsRepo` | `ProjectDocsRepo` | - |  |
| `docsOutbox` | `DocsOutbox[]` | ✓ |  |
| `docGenerationRuns` | `DocGenerationRun[]` | ✓ |  |
| `docsChangeRequests` | `DocsChangeRequest[]` | ✓ |  |
| `docsSync` | `ProjectDocsSync` | - |  |
| `supportAgentConfigs` | `SupportAgentConfig[]` | ✓ |  |
| `chatInteractions` | `ChatInteraction[]` | ✓ |  |
| `chatSessions` | `ChatSession[]` | ✓ |  |
| `chatMessages` | `ChatMessage[]` | ✓ |  |
| `slackIntegrations` | `SlackIntegration[]` | ✓ |  |
| `pmeJobs` | `PmeGenerationJob[]` | ✓ |  |
| `pmePages` | `PmeGeneratedPage[]` | ✓ |  |
| `pmeAssets` | `PmeGeneratedAsset[]` | ✓ |  |
| `docVersions` | `DocVersion[]` | ✓ |  |
| `webhookDeliveries` | `WebhookDelivery[]` | ✓ |  |
| `docPageViews` | `DocPageView[]` | ✓ |  |
| `docSearchQueries` | `DocSearchQuery[]` | ✓ |  |
| `auditEvents` | `AuditEvent[]` | ✓ |  |
| `scheduledReports` | `ScheduledReport[]` | ✓ |  |
| `exportHistory` | `ExportHistory[]` | ✓ |  |
| `branding` | `ProjectBranding` | - |  |
| `accessPolicy` | `ProjectAccessPolicy` | - |  |
| `readerIdentityConfig` | `ReaderIdentityConfig` | - |  |
| `shareLinks` | `DocsShareLink[]` | ✓ |  |
| `docFeedback` | `DocFeedback[]` | ✓ |  |
| `docIssueReports` | `DocIssueReport[]` | ✓ |  |
| `boards` | `Board[]` | ✓ |  |
| `sourceConnectors` | `SourceConnector[]` | ✓ |  |
| `customDomain` | `CustomDomain` | - |  |
| `readerProfiles` | `ReaderProjectProfile[]` | ✓ |  |
| `readerApiKeys` | `ReaderApiKey[]` | ✓ |  |

## Diagram

```mermaid
erDiagram
  PROJECT {
    String id PK
    String name
    String slug
    String description
    String organizationId FK
    String themeId FK
    String repoUrl
    String repoBranch
    Json settings
    DateTime createdAt
  }

  ORGANIZATION ||--o{ PROJECT : owns
  THEME ||--o{ PROJECT : uses
```

## Usage

```ts
import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();

const project = await prisma.project.create({
  data: {
    name: "Atloria Documentation",
    slug: "atloria-docs",
    description: "Documentation site for the Atloria platform.",
    organizationId: "org_123",
    themeId: "theme_default",
    repoUrl: "https://github.com/atloria/docs.git",
    repoBranch: "main",
    settings: {
      deployment: {
        provider: "vercel",
        autoDeploy: true,
      },
      documentation: {
        defaultLocale: "en",
      },
    },
  },
});

const projects = await prisma.project.findMany({
  where: {
    organizationId: "org_123",
  },
  orderBy: {
    createdAt: "desc",
  },
});
```

## AI Coding Instructions

- Scope all project reads and mutations by `organizationId` to preserve tenant isolation.
- Treat `slug` as a stable, URL-safe identifier; validate and normalize it before creating or updating projects.
- Store extensible configuration in `settings`, but validate its expected shape at the application boundary.
- Do not expose repository credentials or sensitive connection data through `repoUrl`, `settings`, or API responses.
- Use `repoBranch` when integrating repository synchronization, build, or deployment workflows.

## Relationships

- HAS_ONE → `Organization`
- HAS_ONE → `Theme`

## Referenced By

- `ProjectMember` (HAS_ONE)
- `Category` (HAS_ONE)
- `KGEntity` (HAS_ONE)
- `Flow` (HAS_ONE)
- `ScreenshotJob` (HAS_ONE)
- `Screenshot` (HAS_ONE)
- `WebhookDelivery` (HAS_ONE)
- `TechnicalStaleEntity` (HAS_ONE)
- `DocsPrConfig` (HAS_ONE)
- `ProjectDocsRepo` (HAS_ONE)
- `DocsOutbox` (HAS_ONE)
- `DocGenerationRun` (HAS_ONE)
- `SupportAgentConfig` (HAS_ONE)
- `SourceConnector` (HAS_ONE)
- `CustomDomain` (HAS_ONE)
- `ChatSession` (HAS_ONE)
- `ChatInteraction` (HAS_ONE)
- `ChatMessage` (HAS_ONE)
- `SlackIntegration` (HAS_ONE)
- `DocsShareLink` (HAS_ONE)
- `DocPageView` (HAS_ONE)
- `DocSearchQuery` (HAS_ONE)
- `DocFeedback` (HAS_ONE)
- `ScheduledReport` (HAS_ONE)
- `ExportHistory` (HAS_ONE)
- `AuditEvent` (HAS_ONE)
- `PmeGenerationJob` (HAS_ONE)
- `PmeGeneratedPage` (HAS_ONE)
- `PmeGeneratedAsset` (HAS_ONE)
- `DocIssueReport` (HAS_ONE)
- `ReaderProjectProfile` (HAS_ONE)
- `ReaderApiKey` (HAS_ONE)
- `ProjectDocsSync` (HAS_ONE)
