This repository has been archived on 2026-11-17. You can view files and clone it, but cannot push or open issues or pull requests.
gitgram-ai/gitgram/backend/prisma/schema-backup-20251203.prisma
caelum0x 49b183818c Unify gitgram + aitimemachine into the monorepo (de-submodule) and merge vendored engines
Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as
opaque submodule gitlinks on GitHub) into fully-tracked first-party content.

AITM now merges its 7 vendored repos as first-party engines:
- memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts
- git: vendored C git (bundled binary) + gitnexus (in-process code intelligence)
- agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess)

Includes the full session's product build: Gitgram web/mobile/backend features,
AITM website/CLI/MCP, the unified memory layer, engine build tooling
(scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md),
and extensive test suites.

Build artifacts, node_modules, external/, and gemini-cli are gitignored.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 14:14:09 +03:00

718 lines
18 KiB
Plaintext

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id String @id @default(cuid())
username String @unique
email String @unique
password String?
githubId String? @unique
githubUsername String?
githubAccessToken String?
googleId String? @unique
avatar String?
bio String?
website String?
location String?
verified Boolean @default(false)
premium Boolean @default(false)
twoFactorEnabled Boolean @default(false)
twoFactorSecret String?
emailVerified Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
posts Post[]
comments Comment[]
likes Like[]
followers Follow[] @relation("followers")
following Follow[] @relation("following")
sentMessages Message[] @relation("sender")
receivedMessages Message[] @relation("receiver")
notifications Notification[]
stories Story[]
sessions Session[]
repositoryFollows RepositoryFollow[]
repositoryBookmarks RepositoryBookmark[]
reels Reel[]
reelLikes ReelLike[]
reelComments ReelComment[]
reelViews ReelView[]
storyViews StoryView[]
@@index([username])
@@index([email])
@@index([githubId])
@@index([googleId])
}
model Session {
id String @id @default(cuid())
userId String
refreshToken String @unique
expiresAt DateTime
createdAt DateTime @default(now())
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([userId])
@@index([refreshToken])
}
model Post {
id String @id @default(cuid())
userId String
content String @db.Text
mediaUrls String[]
gifUrl String? // Giphy GIF URL
repoUrl String?
repoData Json?
projectId String?
repoOwner String?
repoName String?
repositoryId String?
type PostType @default(POST)
likesCount Int @default(0)
commentsCount Int @default(0)
viewsCount Int @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
repository Repository? @relation("RepositoryPosts", fields: [repositoryId], references: [id])
comments Comment[]
likes Like[]
postHashtags PostHashtag[]
savedPosts SavedPost[]
@@index([userId])
@@index([projectId])
@@index([repositoryId])
@@index([type])
@@index([createdAt])
}
model Comment {
id String @id @default(cuid())
postId String
userId String
content String @db.Text
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([postId])
@@index([userId])
}
model Like {
id String @id @default(cuid())
postId String
userId String
createdAt DateTime @default(now())
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([postId, userId])
@@index([postId])
@@index([userId])
}
model Follow {
id String @id @default(cuid())
followerId String
followingId String
createdAt DateTime @default(now())
follower User @relation("followers", fields: [followerId], references: [id], onDelete: Cascade)
following User @relation("following", fields: [followingId], references: [id], onDelete: Cascade)
@@unique([followerId, followingId])
@@index([followerId])
@@index([followingId])
}
model Message {
id String @id @default(cuid())
senderId String
receiverId String?
chatId String?
content String @db.Text
mediaUrl String?
gifUrl String? // Giphy GIF URL
read Boolean @default(false)
createdAt DateTime @default(now())
sender User @relation("sender", fields: [senderId], references: [id], onDelete: Cascade)
receiver User? @relation("receiver", fields: [receiverId], references: [id], onDelete: Cascade)
chat Chat? @relation(fields: [chatId], references: [id], onDelete: Cascade)
@@index([senderId])
@@index([receiverId])
@@index([chatId])
@@index([createdAt])
}
model Chat {
id String @id @default(cuid())
name String?
isGroup Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
messages Message[]
members ChatMember[]
@@index([isGroup])
}
model ChatMember {
id String @id @default(cuid())
chatId String
userId String
role ChatRole @default(MEMBER)
joinedAt DateTime @default(now())
chat Chat @relation(fields: [chatId], references: [id], onDelete: Cascade)
@@unique([chatId, userId])
@@index([chatId])
@@index([userId])
}
enum ChatRole {
ADMIN
MEMBER
}
model Notification {
id String @id @default(cuid())
userId String
type NotificationType
actorId String?
postId String?
content String
read Boolean @default(false)
createdAt DateTime @default(now())
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([userId])
@@index([read])
@@index([createdAt])
}
model Hashtag {
id String @id @default(cuid())
name String @unique
count Int @default(0)
trending Boolean @default(false)
createdAt DateTime @default(now())
postHashtags PostHashtag[]
@@index([name])
@@index([trending])
}
model PostHashtag {
id String @id @default(cuid())
postId String
hashtagId String
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
hashtag Hashtag @relation(fields: [hashtagId], references: [id], onDelete: Cascade)
@@unique([postId, hashtagId])
@@index([postId])
@@index([hashtagId])
}
model Story {
id String @id @default(cuid())
userId String
repositoryId String?
mediaType String @default("image") // 'image' or 'video'
mediaUrl String
thumbnailUrl String?
duration Int? // For videos
caption String? @db.Text
viewsCount Int @default(0)
expiresAt DateTime
createdAt DateTime @default(now())
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
repository Repository? @relation(fields: [repositoryId], references: [id])
views StoryView[]
reactions StoryReaction[]
replies StoryReply[]
@@index([userId])
@@index([repositoryId])
@@index([expiresAt])
@@index([createdAt])
}
model StoryView {
id String @id @default(cuid())
storyId String
userId String
createdAt DateTime @default(now())
story Story @relation(fields: [storyId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([storyId, userId])
@@index([storyId])
@@index([userId])
}
model StoryReaction {
id String @id @default(cuid())
storyId String
userId String
type String // 'heart', 'fire', 'laugh', 'wow', 'sad', 'angry'
createdAt DateTime @default(now())
story Story @relation(fields: [storyId], references: [id], onDelete: Cascade)
@@unique([storyId, userId])
@@index([storyId])
@@index([userId])
}
model StoryReply {
id String @id @default(cuid())
storyId String
userId String
content String @db.Text
createdAt DateTime @default(now())
story Story @relation(fields: [storyId], references: [id], onDelete: Cascade)
@@index([storyId])
@@index([userId])
}
model Mention {
id String @id @default(cuid())
userId String // user being mentioned
postId String?
commentId String?
createdAt DateTime @default(now())
@@index([userId])
@@index([postId])
@@index([commentId])
}
model SavedCollection {
id String @id @default(cuid())
userId String
name String
isPrivate Boolean @default(true)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
items SavedCollectionItem[]
savedPosts SavedPost[] @relation("CollectionItems")
@@index([userId])
}
model SavedPost {
id String @id @default(cuid())
userId String
postId String
collectionId String?
createdAt DateTime @default(now())
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
collection SavedCollection? @relation("CollectionItems", fields: [collectionId], references: [id], onDelete: SetNull)
@@unique([userId, postId])
@@index([userId])
@@index([postId])
@@index([collectionId])
}
model SavedCollectionItem {
id String @id @default(cuid())
collectionId String
postId String
createdAt DateTime @default(now())
collection SavedCollection @relation(fields: [collectionId], references: [id], onDelete: Cascade)
@@unique([collectionId, postId])
@@index([collectionId])
@@index([postId])
}
model PostShare {
id String @id @default(cuid())
userId String
postId String
comment String?
createdAt DateTime @default(now())
@@unique([userId, postId])
@@index([userId])
@@index([postId])
}
model PostReport {
id String @id @default(cuid())
userId String
postId String
reason String
createdAt DateTime @default(now())
@@index([userId])
@@index([postId])
}
model UserBlock {
id String @id @default(cuid())
blockerId String
blockedId String
createdAt DateTime @default(now())
@@unique([blockerId, blockedId])
@@index([blockerId])
@@index([blockedId])
}
enum PostType {
POST
REEL
STORY
}
enum NotificationType {
LIKE
COMMENT
FOLLOW
MENTION
MESSAGE
}
model Project {
id String @id @default(cuid())
githubId String @unique
name String
owner String
description String? @db.Text
url String
stars Int @default(0)
forks Int @default(0)
language String?
userId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([userId])
@@index([owner, name])
}
model Repository {
id String @id @default(cuid())
owner String
name String
fullName String
description String? @db.Text
stars Int @default(0)
forks Int @default(0)
watchers Int @default(0)
openIssues Int @default(0)
language String?
topics String[]
avatarUrl String?
htmlUrl String
trending Boolean @default(false)
trendingScore Float @default(0)
lastFetched DateTime @default(now())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
posts Post[] @relation("RepositoryPosts")
followers RepositoryFollow[]
views RepositoryView[]
bookmarks RepositoryBookmark[]
reels Reel[]
stories Story[]
@@unique([owner, name])
@@index([owner])
@@index([name])
@@index([language])
@@index([stars])
@@index([trending])
@@index([lastFetched])
}
model RepositoryFollow {
id String @id @default(cuid())
userId String
repositoryId String
createdAt DateTime @default(now())
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
repository Repository @relation(fields: [repositoryId], references: [id], onDelete: Cascade)
@@unique([userId, repositoryId])
@@index([userId])
@@index([repositoryId])
}
model Subscription {
id String @id @default(uuid())
userId String @unique
plan String // free, premium, creator
status String // active, canceled, expired
stripeCustomerId String? @unique
stripeSubscriptionId String? @unique
currentPeriodEnd DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([userId])
@@index([status])
}
model Analytics {
id String @id @default(uuid())
userId String
date DateTime @default(now())
views Int @default(0)
likes Int @default(0)
comments Int @default(0)
shares Int @default(0)
followers Int @default(0)
reach Int @default(0)
engagement Float @default(0)
@@unique([userId, date])
@@index([userId])
@@index([date])
}
model ScheduledPost {
id String @id @default(uuid())
userId String
content String
mediaUrls String[]
scheduledFor DateTime
status String @default("pending") // pending, published, failed
createdAt DateTime @default(now())
@@index([userId])
@@index([scheduledFor])
@@index([status])
}
model Advertisement {
id String @id @default(uuid())
advertiserId String
type String // post, story, reel
content String
mediaUrl String?
targetAudience Json?
budget Float
spent Float @default(0)
impressions Int @default(0)
clicks Int @default(0)
status String @default("active") // active, paused, completed
startDate DateTime
endDate DateTime
createdAt DateTime @default(now())
@@index([advertiserId])
@@index([status])
@@index([startDate])
}
model ModerationLog {
id String @id @default(uuid())
userId String
content String @db.Text
flags String
scores String @db.Text
action String // approve, review, reject, flag
category String?
createdAt DateTime @default(now())
@@index([userId])
@@index([action])
@@index([createdAt])
}
model NotificationPreferences {
id String @id @default(uuid())
userId String @unique
likes Boolean @default(true)
comments Boolean @default(true)
follows Boolean @default(true)
mentions Boolean @default(true)
messages Boolean @default(true)
posts Boolean @default(true)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([userId])
}
// User preferences for personalized recommendations
model UserLanguagePreference {
id String @id @default(cuid())
userId String
language String
score Float @default(1.0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([userId, language])
@@index([userId])
@@index([language])
}
model UserTopicInterest {
id String @id @default(cuid())
userId String
topic String
score Float @default(1.0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([userId, topic])
@@index([userId])
@@index([topic])
}
// Repository interactions for recommendation algorithm
model RepositoryView {
id String @id @default(cuid())
userId String
repositoryId String
createdAt DateTime @default(now())
repository Repository @relation(fields: [repositoryId], references: [id], onDelete: Cascade)
@@index([userId])
@@index([repositoryId])
@@index([createdAt])
}
// Reels - Short-form video content for repositories
model Reel {
id String @id @default(cuid())
userId String
repositoryId String?
title String
description String? @db.Text
videoUrl String // S3 or CDN URL
thumbnailUrl String
duration Int // Duration in seconds
width Int?
height Int?
viewsCount Int @default(0)
likesCount Int @default(0)
commentsCount Int @default(0)
sharesCount Int @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
repository Repository? @relation(fields: [repositoryId], references: [id])
likes ReelLike[]
comments ReelComment[]
views ReelView[]
@@index([userId])
@@index([repositoryId])
@@index([createdAt])
@@index([viewsCount])
}
model ReelLike {
id String @id @default(cuid())
reelId String
userId String
createdAt DateTime @default(now())
reel Reel @relation(fields: [reelId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([reelId, userId])
@@index([reelId])
@@index([userId])
}
model ReelComment {
id String @id @default(cuid())
reelId String
userId String
content String @db.Text
createdAt DateTime @default(now())
reel Reel @relation(fields: [reelId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([reelId])
@@index([userId])
}
model ReelView {
id String @id @default(cuid())
reelId String
userId String? // Null for anonymous views
createdAt DateTime @default(now())
reel Reel @relation(fields: [reelId], references: [id], onDelete: Cascade)
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([reelId])
@@index([userId])
@@index([createdAt])
}
model RepositoryBookmark {
id String @id @default(cuid())
userId String
repositoryId String
createdAt DateTime @default(now())
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
repository Repository @relation(fields: [repositoryId], references: [id], onDelete: Cascade)
@@unique([userId, repositoryId])
@@index([userId])
@@index([repositoryId])
}
// Trending repositories cache
model TrendingRepository {
id String @id @default(cuid())
repositoryId String
period String // 'daily', 'weekly', 'monthly'
rank Int
score Float
createdAt DateTime @default(now())
@@unique([repositoryId, period])
@@index([period, rank])
@@index([createdAt])
}