LeetCode-style problems with visual explanations and downloadable Hinglish PDFs
Built with Next.js 14 · Prisma · PostgreSQL · NextAuth · Stripe · Cloudinary
codes-on-notes/
├── app/
│ ├── api/
│ │ ├── auth/
│ │ │ ├── [...nextauth]/route.ts ← NextAuth handler
│ │ │ └── register/route.ts ← User signup
│ │ ├── problems/
│ │ │ ├── route.ts ← List / Create problems
│ │ │ └── [slug]/
│ │ │ ├── route.ts ← Get / Edit / Delete problem
│ │ │ └── solve/route.ts ← Mark solved + streak update
│ │ ├── bookmarks/route.ts ← Toggle bookmarks
│ │ ├── execute/route.ts ← Judge0 code execution
│ │ ├── roadmap/route.ts ← DSA roadmap
│ │ ├── users/me/route.ts ← User dashboard stats
│ │ ├── admin/upload/route.ts ← PDF/image upload (Cloudinary)
│ │ └── stripe/
│ │ ├── checkout/route.ts ← Create Stripe session
│ │ └── webhook/route.ts ← Handle payment events
│ ├── problems/ ← Problems page
│ ├── roadmap/ ← Roadmap page
│ ├── playground/ ← Code playground
│ ├── dashboard/ ← User dashboard
│ ├── premium/ ← Premium plans
│ └── admin/ ← Admin dashboard
├── components/ ← Reusable UI components
├── lib/
│ ├── prisma.ts ← Prisma client singleton
│ ├── auth.ts ← NextAuth config
│ ├── cloudinary.ts ← File upload helper
│ ├── stripe.ts ← Payment logic
│ └── streak.ts ← Streak tracking
├── prisma/
│ ├── schema.prisma ← Full database schema
│ └── seed.ts ← Seed data
├── middleware.ts ← Route protection
├── types/index.ts ← Shared TypeScript types
└── .env.example ← Environment variable template
- Node.js v18+ → https://nodejs.org
- PostgreSQL v14+ → https://postgresql.org (or use Neon.tech free cloud DB)
- npm or pnpm
# Clone the repo
git clone https://github.com/yourusername/codes-on-notes.git
cd codes-on-notes
# Install all dependencies
npm install# Copy the example file
cp .env.example .env.localOpen .env.local and fill in:
| Variable | Where to get it |
|---|---|
NEXTAUTH_SECRET |
Run: openssl rand -base64 32 |
DATABASE_URL |
Your PostgreSQL connection string |
GOOGLE_CLIENT_ID/SECRET |
console.cloud.google.com |
GITHUB_ID/SECRET |
github.com/settings/developers |
CLOUDINARY_* |
cloudinary.com → Dashboard |
STRIPE_* |
dashboard.stripe.com |
JUDGE0_API_KEY |
rapidapi.com/judge0 |
Option A: Local PostgreSQL
# Create database
psql -U postgres
CREATE DATABASE codesonnotes;
\q
# Set in .env.local:
DATABASE_URL=postgresql://postgres:yourpassword@localhost:5432/codesonnotesOption B: Neon (Free Cloud DB — Recommended)
- Go to neon.tech → Create account → New Project
- Copy the connection string
- Paste into
.env.localasDATABASE_URL
# Push the schema to your database
npm run db:push
# OR for production-grade migrations:
npm run db:migratenpm run db:seedThis creates:
- Admin account:
admin@codesonnotes.in/admin123 - Demo account:
demo@codesonnotes.in/demo123 - 13 topics, 2 sample problems, full roadmap structure, and sample resources
npm run devOpen http://localhost:3000 🎉
- Go to console.cloud.google.com
- Create project → APIs & Services → Credentials → OAuth 2.0 Client
- Authorized redirect URI:
http://localhost:3000/api/auth/callback/google - Copy Client ID and Secret into
.env.local
- Go to github.com/settings/developers
- New OAuth App → Homepage:
http://localhost:3000 - Callback URL:
http://localhost:3000/api/auth/callback/github - Copy Client ID and Secret into
.env.local
- Go to dashboard.stripe.com → Products
- Create 3 products:
- FAANG DSA Sheet → ₹499 one-time
- Blind 75 Visual Guide → ₹349 one-time
- Full Access Bundle → ₹999 one-time
- Copy each product's Price ID into
.env.local - For local webhook testing:
# Install Stripe CLI
brew install stripe/stripe-cli/stripe # Mac
# or download from: https://stripe.com/docs/stripe-cli
# Forward webhooks to local server
stripe listen --forward-to localhost:3000/api/stripe/webhook
# Copy the webhook secret shown and add to .env.local
STRIPE_WEBHOOK_SECRET=whsec_...npm run dev # Start dev server (localhost:3000)
npm run build # Production build
npm run start # Start production server
npm run db:push # Sync schema to DB (dev only)
npm run db:migrate # Create migration files
npm run db:studio # Open Prisma Studio (visual DB editor)
npm run db:seed # Seed the databasenpm run db:studioOpens at http://localhost:5555 — view and edit all tables visually.
git init
git add .
git commit -m "initial commit"
git remote add origin https://github.com/yourusername/codes-on-notes.git
git push -u origin main- Go to vercel.com → New Project
- Import your GitHub repo
- Framework: Next.js (auto-detected)
In Vercel dashboard → Settings → Environment Variables:
- Add all variables from
.env.example - Update
NEXTAUTH_URLto your Vercel URL:https://your-app.vercel.app - Update OAuth callback URLs to your Vercel domain
vercel --prod# One-time: run migrations against production DB
DATABASE_URL=your-production-db-url npx prisma migrate deploy
DATABASE_URL=your-production-db-url npx tsx prisma/seed.tsAccess at: /admin (requires ADMIN role)
Features:
- Add / Edit / Delete problems
- Upload PDFs to Cloudinary
- Manage topics and roadmap
- View all users
- Manage resources
Change user role to ADMIN:
# In Prisma Studio, or run:
npx prisma studio
# Find your user → change role to ADMINUser ──────────── UserProblem (solved)
│ └─ Bookmark
│ └─ Streak
│ └─ Submission
│ └─ RoadmapProgress
│
Problem ──────── Solution (per language)
│ └─ Topic
│ └─ pdfUrl (Cloudinary)
│ └─ visualCode (sandboxed)
│
RoadmapLevel ─── RoadmapTopic ─── Topic
Resource ──────── fileUrl (Cloudinary)
After seeding:
| Role | Password | |
|---|---|---|
| Admin | admin@codesonnotes.in | admin123 |
| User | demo@codesonnotes.in | demo123 |
| Package | Purpose |
|---|---|
next-auth |
Authentication (Google, GitHub, Email) |
@prisma/client |
Database ORM |
bcryptjs |
Password hashing |
cloudinary |
PDF & image storage |
stripe |
Payments |
zod |
API input validation |
zustand |
Client state management |
framer-motion |
Animations |
- Instagram: @codes.on.notes
- YouTube: @codes.on.notes
Built with ❤️ for the DSA community.