Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Alex – MCAT Exam Study

Next.js app with PostgreSQL: sections, segments, and questions are stored in the database. Progress and daily stats are persisted per client (anonymous client_id in localStorage).

Setup

  1. Create a PostgreSQL database
    Use Vercel Storage (e.g. Neon), Supabase, or any Postgres host. Copy the connection string.

  2. Environment
    Create .env in the project root:

    DATABASE_URL=postgresql://...
  3. Schema and seed
    From the project root:

    npm install
    npm run db:setup
    npm run db:seed

    (db:seed requires scripts/seed-questions.json; run node scripts/extract-seed-json.js once to generate it from demo.js.)

  4. Run locally

    npm run dev

    Open http://localhost:3000.

Performance Optimizations

This system includes comprehensive performance optimizations for faster response times and better scalability:

Database Optimizations

  • Connection Pooling: Optimized with configurable timeouts (2 connections in dev, 10 in production)
  • Performance Indexes: Added 5 indexes including filtered indexes for faster queries:
    • idx_questions_segment_id - For segment-based queries
    • idx_questions_segment_custom - Combined segment and custom flags
    • idx_progress_client_id - Client progress lookups
    • idx_daily_client_id_day - Daily stats queries
    • idx_questions_custom_client - Custom questions filtering

API Optimizations

  • Response Caching: Sections and questions APIs cache data for 1 minute to reduce database load
  • Query Optimization: Combined JOIN operations where beneficial
  • Object Building: Optimized using functional programming patterns (reduce() instead of forEach)

Client-Side Optimizations

  • Client ID Caching: Memoized client ID generation to reduce localStorage operations
  • Error Handling: Improved async/await patterns for better error handling

Expected Performance Improvements

  • Database Queries: 40-60% faster with new indexes
  • API Responses: 30-50% faster with caching
  • Page Loads: 15-25% faster with client-side optimizations

Deploy on Vercel (project name: Alex) this is just a test edit accordingly.

  1. Push the repo and import the project in Vercel under your account (e.g. under "juelzs" / your team). Name the project Alex.

  2. In Vercel → Project → Settings → Environment Variables, add:

    • DATABASE_URL = your Postgres connection string (Production, Preview, Development if needed).
  3. After the first deploy, run migrations and seed against the same database (from your machine or a one-off script):

    DATABASE_URL="your-production-url" npm run db:setup
    DATABASE_URL="your-production-url" npm run db:seed
  4. Redeploy or trigger a new deployment so the app uses the seeded data.

Deploy on Vercel (project name: Alex) this is just a test edit accordingly.

  1. Push the repo and import the project in Vercel under your account (e.g. under “juelzs” / your team). Name the project Alex.

  2. In Vercel → Project → Settings → Environment Variables, add:

    • DATABASE_URL = your Postgres connection string (Production, Preview, Development if needed).
  3. After the first deploy, run migrations and seed against the same database (from your machine or a one-off script):

    DATABASE_URL="your-production-url" npm run db:setup
    DATABASE_URL="your-production-url" npm run db:seed
  4. Redeploy or trigger a new deployment so the app uses the seeded data.

Scripts

  • npm run dev – local dev server
  • npm run build – production build
  • npm run start – run production build locally
  • npm run db:setup – apply scripts/schema.sql
  • npm run db:seed – insert sections and questions (requires seed-questions.json)
  • node scripts/extract-seed-json.js – generate seed-questions.json from demo.js

Data model

  • sections / segments – MCAT sections and segments (labels, colors, icons).
  • questions – seed questions plus custom questions per client_id.
  • progress – per client/segment/question: attempts, correct, streak, notes, last_seen.
  • daily – per client/day: attempts and correct count.

All content is read from the database; no hardcoded question bank in the app.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages