Skip to content
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

feat: support for CRUD on files from cloudflare #24

Merged
merged 19 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# To get these values, you can either:
# - Message @Nyumat on Discord
# - Create your own accounts and get the values from the respective services
# - Pinecone: https://www.pinecone.io/
# - OpenAI: https://platform.openai.com/
# - Cloudflare R2: https://www.cloudflare.com/products/cloudflare-r2/

# Authentication Secrets
AUTH_SECRET=""
AUTH_GOOGLE_ID=""
AUTH_GOOGLE_SECRET=""

# Database Configuration
DATABASE_URL="postgresql://<username>:<password>@<host>:<port>/<database_name>"

# Pinecone Configuration
PINECONE_API_KEY=""
PINECONE_INDEX_NAME=""

# OpenAI Configuration
OPENAI_API_KEY=""

# Cloudflare R2 Configuration
R2_ACCOUNT_ID=""
R2_TOKEN_VALUE=""
R2_ACCESS_KEY_ID=""
R2_SECRET_ACCESS_KEY=""
R2_URL="https://<account_id>.r2.cloudflarestorage.com"
R2_BUCKET_NAME=""
R2_TOKEN_NAME=""
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,14 @@ jobs:
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }}
PINECONE_INDEX_NAME: ${{ secrets.PINECONE_INDEX_NAME }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
AUTH_SECRET: ${{ secrets.AUTH_SECRET }}
AUTH_GOOGLE_ID: ${{ secrets.AUTH_GOOGLE_ID }}
AUTH_GOOGLE_SECRET: ${{ secrets.AUTH_GOOGLE_SECRET }}
R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
R2_TOKEN_VALUE: ${{ secrets.R2_TOKEN_VALUE }}
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
R2_URL: ${{ secrets.R2_URL }}
R2_BUCKET_NAME: ${{ secrets.R2_BUCKET_NAME }}
R2_TOKEN_NAME: ${{ secrets.R2_TOKEN_NAME }}
run: npm run build
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ yarn-debug.log*
yarn-error.log*

# env files (can opt-in for commiting if needed)
.env*
.env.local

# vercel
.vercel
Expand Down
62 changes: 53 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Beavs AI is an application that provides an AI Chatbot that is knowledgeable abo
2. Navigate to the project directory:

```bash
cd ./beavsai
cd beavsai
```

3. Install all the required dependencies to run our Next.js App
Expand All @@ -27,36 +27,80 @@ Beavs AI is an application that provides an AI Chatbot that is knowledgeable abo
> [!NOTE]
> You may come across an peer dependency error when running this command, try `npm install --legacy-peer-deps`

4. Create an `.env.local` file in the root directory of the project and add the following environment variables:
4. Copy the `.env.example` file to `.env.local`:

```bash
DATABASE_URL="postgresql://prisma_user:prisma_password@localhost:5432/prisma_db"
AUTH_GOOGLE_ID=
AUTH_GOOGLE_SECRET=
cp .env.example .env.local
```

5. Message [@nyumat](https://discord.com/users/700444827287945316) on Discord to get the OAuth credentials for the application.
5. Message [@nyumat](https://discord.com/users/700444827287945316) on Discord to get the required credentials for the `.env.local` file.

> [!WARNING]
> Do not share these credentials with anyone else. You will not be able to run the application without them.
> Do not share these credentials with anyone else. Additionally, you will not be able to run the application without them.

6. Create an AUTH_SECRET environment variable

```bash
npx auth secret
```

7. Start a local PostgreSQL database using Docker
7. Start a local instance of our PostgreSQL database using [Docker](https://www.docker.com/):

```bash
docker compose up -d
docker-compose up -d
```

> [!NOTE]
> Doing this in VSCode's terminal may present you with an error like:
> Error: P1010: User `postgres` was denied access on the database `postgres`.
> To fix this, use your system's terminal to run the command.

8. Run the Next.js App
```bash
npm run dev
```

## Scripts

<!-- Yeah this is messy, but please don't modify it! (since it works) If you do, paper-trail on Discord. Thanks! -->

| Script | Description |
| -------------- | ---------------------------------------------------------------------------------------------- |
| `dev` | Runs database generation, migration, and starts the Next.js dev server with Turbopack enabled. |
| `build` | Builds the Next.js application for production. |
| `start` | Starts the Next.js application in production mode. |
| `lint` | Runs ESLint to check for code quality issues. |
| `format` | Formats the codebase with Prettier. |
| `check-format` | Checks code formatting without making changes. |
| `type-check` | Runs TypeScript type checks based on the configuration in `tsconfig.json`. |
| `db:generate` | Generates Prisma client based on schema and `.env.local` configuration. |
| `db:migrate` | Applies migrations for development using `.env.local` configuration. |
| `db:studio` | Opens Prisma Studio for database management. |

## Troubleshooting

If you encounter any issues while running the application, please refer to the following troubleshooting steps:

1. **Database Connection Issues**: If you are unable to connect to the database, ensure that the Docker container is running. You can check the status of the container by running the following command:

```bash
docker ps
```

If the container is not running, you can start it using the following command:

```bash
docker-compose up -d
```

2. **Environment Variables**: Ensure that you have copied the `.env.example` file to `.env.local` and have filled in the required credentials. If you are missing any credentials, please message [@nyumat](https://discord.com/users/700444827287945316) on Discord.

3. **Prisma Client Generation**: If you are encountering issues with the Prisma client, you can regenerate it by running the following command:

```bash
npm run db:generate
```

## Contributors

<a href="https://github.com/osu-app-club/beavsai/graphs/contributors">
Expand Down
Loading
Loading