Skip to content

Commit

Permalink
Server-Side-Storage (SSS): use Prisma
Browse files Browse the repository at this point in the history
  • Loading branch information
enricoros committed Oct 16, 2023
1 parent 7aaae21 commit 6022aee
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# [Recommended] Important application information
NEXT_PUBLIC_PRIVACY_POLICY_URL=

# [Recommended, optional] Postgres Database (for server-side storage, see prisma/schema.prisma)
POSTGRES_PRISMA_URL=
POSTGRES_URL_NON_POOLING=

# [Recommended for local deployments] Backend API key for OpenAI, so that users don't need one (UI > this > '')
OPENAI_API_KEY=
# [Optional] Sets the "OpenAI-Organization" header field to support organization users (UI > this > '')
Expand Down
51 changes: 51 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"env:pull": "npx vercel env pull .env.development.local",
"postinstall": "prisma generate",
"db:push": "prisma db push",
"db:studio": "prisma studio"
},
"dependencies": {
"@dqbd/tiktoken": "^1.0.7",
Expand All @@ -20,6 +24,7 @@
"@mui/icons-material": "^5.14.3",
"@mui/joy": "^5.0.0-beta.2",
"@next/bundle-analyzer": "^13.4.19",
"@prisma/client": "^5.4.2",
"@tanstack/react-query": "^4.33.0",
"@trpc/client": "^10.37.1",
"@trpc/next": "^10.37.1",
Expand Down Expand Up @@ -55,6 +60,7 @@
"eslint": "^8.47.0",
"eslint-config-next": "^13.4.19",
"prettier": "^3.0.2",
"prisma": "^5.4.2",
"typescript": "^5.1.6"
}
}
26 changes: 26 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Prisma is the ORM for server-side (API) access to the database
//
// This file defines the schema for the database.
// - make sure to run 'prisma generate' after making changes to this file
// - make sure to run 'prisma db push' to sync the remote database with the schema
//
// Database is optional: when the environment variables are not set, the database is not used at all,
// and the storage of data in Big-AGI is limited to client-side (browser) storage.
//
// The database is used for:
// - the 'sharing' function, to let users share the chats with each other

generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("POSTGRES_PRISMA_URL") // uses connection pooling
directUrl = env("POSTGRES_URL_NON_POOLING") // uses a direct connection
}

model Sharing {
id String @id @default(uuid())
// TODO: to be defined later
}
4 changes: 4 additions & 0 deletions src/common/types/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ declare namespace NodeJS {
// available to the server-side
interface ProcessEnv {

// Postgres, for optional storage via Prisma
POSTGRES_PRISMA_URL?: string;
POSTGRES_URL_NON_POOLING?: string;

// LLM: OpenAI
OPENAI_API_KEY: string;
OPENAI_API_ORG_ID: string;
Expand Down

1 comment on commit 6022aee

@vercel
Copy link

@vercel vercel bot commented on 6022aee Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

big-agi – ./

big-agi-git-main-enricoros.vercel.app
big-agi-enricoros.vercel.app
get.big-agi.com

Please sign in to comment.