Skip to content
Open
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
9 changes: 8 additions & 1 deletion notes-aid/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,11 @@ next-env.d.ts

# Ignore service worker file in public
/public/service-worker.js
/public/workbox-*.js
/public/workbox-*.js

# Prisma
prisma/.env
prisma/migrations/

# Local environment variables
.env
65 changes: 65 additions & 0 deletions notes-aid/README-DATABASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Notes-Aid Database Integration

## Overview
This project uses **PostgreSQL** (hosted on Supabase) with **Prisma ORM** for type-safe, scalable database access. Authentication is managed via **NextAuth.js** with support for OAuth providers (GitHub, Google).

## Setup Steps

1. **Install dependencies:**
```bash
npm install
```
2. **Configure environment variables:**
- Copy `.env.example` to `.env` and fill in your credentials (DATABASE_URL, NextAuth secrets, OAuth keys).
3. **Prisma setup:**
```bash
npx prisma generate
npx prisma migrate dev --name init
```
4. **Run the development server:**
```bash
npm run dev
```

## Database Schema
- **User:** Profiles, preferences, authentication
- **UserProgress:** Tracks completion of videos/notes
- **UserAnalytics:** Usage analytics and activity
- **ContentCache:** Caching for performance
- **Account, Session, VerificationToken:** NextAuth.js tables

## Useful Commands
- `npx prisma studio` – Visual database browser
- `npx prisma migrate dev` – Run migrations
- `npx prisma generate` – Generate Prisma client

## Production Notes
- Use a managed PostgreSQL instance (Supabase recommended)
- Set strong secrets for NextAuth
- Monitor query performance and enable connection pooling

## More Info
- See `prisma/schema.prisma` for the full schema
- See API route files for usage examples

## .env Format Example

Create a `.env` file in your `notes-aid` directory with the following content (replace values as needed):

```
# Database
DATABASE_URL=postgresql://USER:PASSWORD@HOST:PORT/DATABASE

# NextAuth.js
NEXTAUTH_SECRET=your_nextauth_secret
NEXTAUTH_URL=http://localhost:3000

# OAuth Providers (Google, GitHub)
GITHUB_ID=your_github_client_id
GITHUB_SECRET=your_github_client_secret
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
```

- Do **not** commit your real `.env` file to git. Only `.env.example` should be tracked.
- See `.env.example` for a template.
13 changes: 13 additions & 0 deletions notes-aid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,16 @@ You can check out [the Next.js GitHub repository](https://github.com/vercel/next
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.

## 🚀 Database Integration & User Progress

- Integrated scalable PostgreSQL database (Supabase) using Prisma ORM for type-safe, performant access.
- Added NextAuth.js authentication with Google OAuth for secure user login and session management.
- Implemented secure API endpoints for user progress, analytics, and preferences, all protected by authentication.
- Linked progress tracking UI to the database for logged-in users—progress is now persistent and user-specific.
- Role-based access control (admin/user) for secure admin endpoints.
- Provided .env.example and updated documentation for easy setup.

See `README-DATABASE.md` for setup and usage instructions.

---
Loading