Skip to content

Commit 568a77c

Browse files
Add lesson, dashboard, and course pages with session management (#801)
* Add lesson and dashboard pages with layout, SEO, and session handling - Implemented lesson page for web development module with video, content, and assignment sections. - Added dashboard page displaying user stats, current courses, upcoming assignments, and recent activity. - Integrated session management using next-auth for user authentication. - Included breadcrumb navigation and SEO optimization for both pages. * Refactor authentication and session management - Updated AdminDashboard to use new styling for links and admin indicator. - Enhanced GitHub sign-in logic to allow development mode and specific user access. - Implemented a fallback for session management in CoursesIndex and Profile pages, allowing for a development session. - Created a new DevLogin page for testing purposes, enabling a quick bypass of GitHub OAuth. - Introduced a custom hook `useDevSession` to manage development sessions. * Add AI Engineering, Data Engineering, and Software Engineering course pages with modules, prerequisites, and session handling * feat: update environment configuration and improve build process for Vercel deployment
1 parent af475b9 commit 568a77c

34 files changed

+7023
-153
lines changed

.env.example

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Database
2+
# For local development, use SQLite:
3+
# DATABASE_URL="file:./dev.db"
4+
# For production, use PostgreSQL (Vercel Postgres, Railway, Supabase, etc.):
5+
DATABASE_URL="postgresql://username:password@hostname:port/database"
6+
7+
# NextAuth.js
8+
NEXTAUTH_SECRET="your-secret-key-here"
9+
NEXTAUTH_URL="http://localhost:3000"
10+
11+
# GitHub OAuth (for authentication)
12+
GITHUB_CLIENT_ID="your-github-client-id"
13+
GITHUB_CLIENT_SECRET="your-github-client-secret"
14+
15+
# Optional: Other OAuth providers
16+
# GOOGLE_CLIENT_ID="your-google-client-id"
17+
# GOOGLE_CLIENT_SECRET="your-google-client-secret"

.env.local.example

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Local development database (SQLite)
2+
DATABASE_URL="file:./dev.db"
3+
4+
# NextAuth.js - Generate a secret with: npx auth secret
5+
NEXTAUTH_SECRET="development-secret-key-replace-in-production"
6+
NEXTAUTH_URL="http://localhost:3000"
7+
8+
# GitHub OAuth for development
9+
GITHUB_CLIENT_ID="your-dev-github-client-id"
10+
GITHUB_CLIENT_SECRET="your-dev-github-client-secret"

DATABASE_GUIDE.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Database Migration Guide for Production
2+
3+
## Current Setup (Development)
4+
5+
- **Database**: SQLite (file:./dev.db)
6+
- **Pros**:
7+
- Zero setup required
8+
- Perfect for development
9+
- Data persists between restarts
10+
- **Cons**:
11+
- Single file, not scalable for multiple users
12+
- Limited concurrent access
13+
14+
## Production Options
15+
16+
### Option 1: PostgreSQL (Recommended)
17+
18+
**Best for production with multiple users**
19+
20+
```bash
21+
# Example production DATABASE_URL
22+
DATABASE_URL="postgresql://username:password@hostname:5432/vwc_production"
23+
```
24+
25+
**Hosting Options:**
26+
27+
- **Vercel Postgres**: Seamless integration with Vercel deployment
28+
- **Supabase**: Free tier available, great for startups
29+
- **PlanetScale**: MySQL-compatible, auto-scaling
30+
- **Railway**: Simple deployment with PostgreSQL
31+
- **AWS RDS**: Enterprise-grade, scalable
32+
33+
### Option 2: Keep SQLite (For Small Scale)
34+
35+
**If you have < 50 concurrent users**
36+
37+
```bash
38+
# Production SQLite with better location
39+
DATABASE_URL="file:/app/data/production.db"
40+
```
41+
42+
**Pros:**
43+
44+
- Simple deployment
45+
- No additional database server needed
46+
- Good for small veteran cohorts
47+
48+
### Option 3: Hybrid Approach
49+
50+
**Start with SQLite, migrate when needed**
51+
52+
1. **Phase 1**: Launch with SQLite for first cohort
53+
2. **Phase 2**: Migrate to PostgreSQL when scaling
54+
3. **Migration**: Prisma handles schema migration automatically
55+
56+
## Migration Steps (When Ready)
57+
58+
### 1. Update Environment Variables
59+
60+
```bash
61+
# In production .env
62+
DATABASE_URL="postgresql://..."
63+
```
64+
65+
### 2. Run Prisma Migration
66+
67+
```bash
68+
npx prisma db push
69+
npx prisma generate
70+
```
71+
72+
### 3. Data Migration (if needed)
73+
74+
```bash
75+
# Export from SQLite
76+
npx prisma db seed
77+
78+
# Import to PostgreSQL
79+
# (Prisma handles this automatically)
80+
```
81+
82+
## Current Data Storage
83+
84+
Your platform currently stores:
85+
86+
- ✅ User profiles with military background
87+
- ✅ Course progress and enrollments
88+
- ✅ Assignment submissions and files
89+
- ✅ Admin analytics and tracking
90+
91+
## File Storage
92+
93+
For user-uploaded files (avatars, assignments):
94+
95+
- **Current**: Local file system
96+
- **Production**: Consider cloud storage (AWS S3, Cloudinary, Vercel Blob)
97+
98+
## Recommendation
99+
100+
**For VWC Launch:**
101+
102+
1. **Start with current SQLite setup** - it's perfect for initial launch
103+
2. **Monitor usage** - migrate to PostgreSQL when you have 20+ concurrent users
104+
3. **Plan migration** - Prisma makes this transition seamless
105+
106+
The platform is production-ready with SQLite for your first veteran cohorts!

DEPLOYMENT.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Deployment Configuration
2+
3+
## Quick Fix for Current Build Issues
4+
5+
The build failure was caused by Prisma trying to run migrations during the Vercel build process without a proper database connection.
6+
7+
### Changes Made:
8+
9+
1. **Updated `package.json`**:
10+
11+
- Changed `vercel-build` script from `prisma generate && prisma migrate deploy && next build`
12+
- To: `prisma generate && next build`
13+
- This removes the migration step that was failing
14+
15+
2. **Environment Setup**:
16+
- Created `.env.local` for local development with SQLite
17+
- Created `.env.example` for reference
18+
- SQLite works for development, but production will need PostgreSQL
19+
20+
### Current Status:
21+
22+
- ✅ Build should now work on Vercel
23+
- ✅ Local development works with SQLite
24+
- ⚠️ Production database needs proper setup
25+
26+
## Next Steps for Production
27+
28+
For a production deployment, you'll need to:
29+
30+
1. **Set up a PostgreSQL database** (recommended providers):
31+
32+
- Vercel Postgres (easiest integration)
33+
- Railway
34+
- Supabase
35+
- PlanetScale
36+
37+
2. **Update Prisma schema** for PostgreSQL:
38+
39+
```prisma
40+
datasource db {
41+
provider = "postgresql"
42+
url = env("DATABASE_URL")
43+
}
44+
```
45+
46+
3. **Set environment variables in Vercel**:
47+
48+
- `DATABASE_URL`: Your PostgreSQL connection string
49+
- `NEXTAUTH_SECRET`: Random secret for NextAuth
50+
- `NEXTAUTH_URL`: Your production URL
51+
- `GITHUB_CLIENT_ID` & `GITHUB_CLIENT_SECRET`: For OAuth
52+
53+
4. **Run initial migration**:
54+
```bash
55+
npx prisma migrate deploy
56+
```
57+
58+
## Local Development
59+
60+
1. Copy `.env.local.example` to `.env.local`
61+
2. Run `npm run dev:setup` to initialize the SQLite database
62+
3. Start development with `npm run dev`
63+
64+
## Authentication Setup
65+
66+
The app uses NextAuth with GitHub OAuth. You'll need to:
67+
68+
1. Create a GitHub OAuth App
69+
2. Set the client ID and secret in your environment variables
70+
3. Configure the callback URL: `http://localhost:3000/api/auth/callback/github`

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
2-
"name": "Vets-Who-Code",
2+
"name": "vets-who-code",
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
66
"dev": "next dev",
7+
"dev:setup": "prisma generate && prisma db push",
78
"build": "next build",
8-
"vercel-build": "prisma generate && prisma migrate deploy && next build",
9+
"vercel-build": "prisma generate && next build",
910
"start": "next start",
1011
"export": "next build && next export",
1112
"format": "prettier --ignore-path .prettierignore --write \"**/*.{js,jsx,ts,tsx,json,md}\"",

prisma/dev.db

140 KB
Binary file not shown.

0 commit comments

Comments
 (0)