Skip to content

bashward/AskPip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 

Repository files navigation

AskPip Frontend

A production-ready Next.js 15 App Router frontend for AskPip - an AI-powered how-to guide platform with interactive chat support.

Features

  • Step-by-Step Guides: Clear, illustrated instructions generated from natural language prompts
  • Interactive Chat: Real-time chat assistance contextualized to the current guide
  • Smart Organization: Pin important guides, auto-expire old ones after 15 days
  • Beautiful UI: Dark mode by default, Tailwind CSS, Framer Motion animations
  • Accessible: WCAG 2.1 AA compliant, full keyboard navigation, screen reader support
  • Responsive: Desktop split-view, mobile drawer, optimized for all screen sizes
  • Authentication: Clerk integration with optional anonymous usage

Tech Stack

  • Framework: Next.js 15 (App Router, JavaScript)
  • Styling: Tailwind CSS 4
  • Animation: Framer Motion
  • Auth: Clerk
  • Database: Supabase (client setup ready)
  • State: Zustand
  • Validation: Zod
  • Icons: Lucide React
  • Theme: next-themes

Installation

  1. Install dependencies:
npm install
  1. Set up environment variables: The .env.local file should already be configured with your API keys. Verify it contains:
# App
NEXT_PUBLIC_APP_NAME=AskPip

# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_...
CLERK_SECRET_KEY=sk_...

# Supabase
NEXT_PUBLIC_SUPABASE_URL=https://xxxx.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJh...
SUPABASE_SERVICE_ROLE_KEY=eyJh...

# Images
NEXT_PUBLIC_IMAGES_BASE=/pip
  1. Run the development server:
npm run dev

Open http://localhost:3000 to view the app.

Project Structure

src/
├── app/                      # Next.js App Router pages
│   ├── api/                  # API route stubs (mock data)
│   │   ├── generateGuide/    # POST - Generate new guide
│   │   ├── guides/           # GET - List guides
│   │   │   └── [id]/         # GET/DELETE - Single guide
│   │   ├── chat/             # POST - SSE chat stream
│   │   └── pin/              # POST - Toggle pin
│   ├── guide/[id]/           # Guide detail page
│   ├── library/              # Library page
│   ├── layout.js             # Root layout with providers
│   ├── page.js               # Landing page
│   └── globals.css           # Global styles
├── components/               # React components
│   ├── NavBar.js            # Top navigation
│   ├── LeftRail.js          # Collapsible side navigation
│   ├── GuideCard.js         # Guide preview card
│   ├── GuideHeader.js       # Guide metadata header
│   ├── StepItem.js          # Individual guide step
│   ├── PipBadge.js          # Character pose badge
│   ├── ProgressBar.js       # Step completion tracker
│   ├── ChatPanel.js         # Chat interface container
│   ├── MessageList.js       # Chat message display
│   ├── Composer.js          # Chat input
│   ├── Skeletons.js         # Loading states
│   └── Toaster.js           # Toast notifications
├── lib/                      # Utility functions
│   ├── api.js               # API client functions
│   ├── supabase.js          # Supabase client setup
│   ├── hashing.js           # Deterministic ID generation
│   └── ttl.js               # 15-day TTL logic
├── store/                    # Zustand state management
│   ├── useGuideStore.js     # Guide data & localStorage
│   ├── useChatStore.js      # Chat messages & persistence
│   └── useUIStore.js        # UI state (rail, drawer)
├── schemas/                  # Zod validation schemas
│   └── guide.js             # Guide/Step/Message schemas
├── types/                    # JSDoc type definitions
│   └── index.js             # TypeScript-style JSDoc types
└── middleware.js             # Clerk auth middleware

public/
└── pip/                      # Pip character poses (SVG)
    ├── point.svg
    ├── thumbs.svg
    ├── think.svg
    └── celebrate.svg

API Routes (Stubs)

All API routes currently return mock data. Replace with Supabase Edge Functions:

POST /api/generateGuide

  • Input: { prompt: string }
  • Output: { id: string, guide: Guide }
  • TODO: Call Gemini Flash → Generate steps → Queue Flux image jobs

GET /api/guides

  • Output: { guides: Guide[] }
  • TODO: Query Supabase with RLS filtered by user

GET /api/guides/[id]

  • Output: { guide: Guide }
  • TODO: Query Supabase with RLS

DELETE /api/guides/[id]

  • Output: { ok: boolean }
  • TODO: Delete from Supabase + schedule image cleanup

POST /api/chat

  • Input: { guideId: string, message: string }
  • Output: SSE stream
  • TODO: Call Gemini Flash with guide context

POST /api/pin

  • Input: { id: string, pinned: boolean }
  • Output: { ok: boolean }
  • TODO: Update Supabase guides table

Data Flow

  1. Anonymous Users: Guides stored in localStorage only, expire after page refresh
  2. Authenticated Users: Same localStorage for now; will sync to Supabase once backend is ready
  3. TTL Logic: Client-side filter removes guides > 15 days old (pinned guides exempt)

Design System

Colors

  • Primary: Blue (#3b82f6)
  • Accent: Purple (#8b5cf6)
  • Muted: Gray tones
  • Surface: Dark backgrounds with layered depth

Typography

  • Font: Inter (system fallback)
  • Scale: 8pt spacing grid

Motion

  • Duration: 150-250ms
  • Easing: ease-in-out
  • Respects: prefers-reduced-motion

Accessibility

  • ✅ WCAG 2.1 AA compliant color contrast (≥4.5:1)
  • ✅ Full keyboard navigation (Tab, Enter, Escape)
  • ✅ Focus visible indicators on all interactive elements
  • ✅ ARIA labels and live regions for dynamic content
  • ✅ Semantic HTML and heading hierarchy
  • ✅ Alt text for all images

Testing

Run Linting

npm run lint

Run E2E Tests (Playwright)

npm run test:e2e

Format Code

npm run format

Deployment

Build for Production

npm run build
npm start

Deploy to Vercel

vercel

Environment variables will need to be configured in Vercel dashboard.

Backend Integration Checklist

  • Replace /api/generateGuide with Supabase Edge Function calling Gemini Flash
  • Replace /api/chat SSE with Gemini Flash streaming
  • Wire up Supabase RLS for guides/steps/messages tables
  • Implement image generation queue (Flux Pro 1.1)
  • Add server-side TTL purge job (replace client-side filtering)
  • Connect Clerk JWT to Supabase auth for RLS
  • Update lib/api.js endpoints to point to Edge Functions
  • Replace localStorage persistence with Supabase queries

Scripts

  • npm run dev - Start development server
  • npm run build - Build for production
  • npm run start - Start production server
  • npm run lint - Run ESLint
  • npm run format - Format with Prettier
  • npm run test:e2e - Run Playwright tests

Contributing

This is a production-ready frontend scaffold. When integrating with the backend:

  1. Update API endpoints in lib/api.js
  2. Add Supabase Edge Function URLs
  3. Configure RLS policies
  4. Test authentication flow
  5. Verify image uploads work
  6. Test TTL cleanup job

License

MIT

Troubleshooting

"Module not found" errors

Run npm install to ensure all dependencies are installed.

Authentication not working

Verify Clerk API keys are correctly set in .env.local.

Styles not loading

Ensure Tailwind CSS is properly configured and globals.css is imported.

Images not appearing

Check that /public/pip/ contains all 4 SVG files (point, thumbs, think, celebrate).


Built with ❤️ for seamless learning experiences.

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published