# Fennie - AI-Powered Academic Tutoring Platform ## Project Overview Fennie is a closed-source SaaS application that provides AI-powered academic tutoring while maintaining strict academic integrity standards. The platform guides students through learning processes rather than providing direct answers, ensuring genuine understanding and ethical academic practices. ## Core Philosophy - **Academic Integrity First**: Never provides direct answers to homework or assignments - **Guided Learning**: Uses step-by-step problem-solving approaches - **Ethical AI**: Cannot be circumvented through clever prompting - **Student-Centered**: Focuses on developing genuine understanding ## Technology Stack ### Frontend - **Next.js 15** with App Router for routing and SSR - **React 19** for UI components - **Tailwind CSS 4** for styling with dark/light theme support - **ShadCN/UI** for pre-built accessible components - **Zustand** for client-side state management - **TypeScript** for type safety ### Backend - **Next.js API Routes** for serverless backend functions - **Prisma ORM** for type-safe database operations - **Supabase Auth** for secure authentication (OAuth + email/password) - **OpenAI SDK** for AI integration (GPT-4o-mini for tutoring) - **MCP (Model Context Protocol)** server for intelligent note management ### Database - **PostgreSQL** with pgvector extension for vector embeddings - **Supabase** for managed database hosting - **Prisma** for schema management and migrations ### AI & ML - **OpenAI GPT-4o-mini** for chat completions and tutoring - **text-embedding-3-small** for semantic search - **Vector embeddings** for context-aware responses - **User memory system** with confidence tracking ### Infrastructure - **Vercel** for deployment and hosting - **Google OAuth** for authentication - **KaTeX** for mathematical equation rendering - **Mermaid** for interactive diagram generation ## Key Features ### Authentication & User Management - OAuth authentication (Google) - Email/password authentication with Supabase - Password reset functionality - Secure session management with JWT ### AI Chat Interface - Real-time chat with AI tutor - Context-aware responses using user notes - Chat history and persistence - Multiple conversation management - Academic integrity enforcement - Mathematical equation support (KaTeX) - Code syntax highlighting - Mermaid diagram rendering ### Knowledge Management - **Notes**: Create, edit, and organize study notes with markdown support - **Documents**: Upload and process PDF/DOCX files for AI context - **User Memory**: AI tracks student knowledge and learning progress - **Vector Search**: Semantic search across notes and documents - **Tags**: Organize content with tagging system ### Study Tools - **Flashcards**: Generate and study flashcard sets - **Quizzes**: Create interactive quizzes from content - **Study Guides**: AI-generated study materials - **Diagnostic Questioning**: Assess baseline understanding ### Collaboration & Sharing - Public sharing of notes and chats via secure tokens - Import/export functionality for collaboration - Blog system for educational content ### SEO & Performance - Server-side rendering (SSR) and static generation (SSG) - Comprehensive meta tags and structured data - XML sitemap generation - Core Web Vitals optimization - OpenGraph image generation ## Project Structure ``` aintegrity/ ├── src/ │ ├── app/ # Next.js App Router pages │ │ ├── (legal)/ # Legal pages (privacy, terms) │ │ ├── api/ # API routes │ │ │ ├── chat/ # Chat endpoints │ │ │ ├── notes/ # Notes CRUD │ │ │ ├── documents/ # Document processing │ │ │ ├── flashcards/ # Flashcard management │ │ │ ├── quizzes/ # Quiz functionality │ │ │ └── user-memory/ # User knowledge tracking │ │ ├── auth/ # Authentication pages │ │ ├── blog/ # Blog system │ │ ├── dashboard/ # Main application interface │ │ ├── shared/ # Public sharing pages │ │ └── lib/ # Utility libraries │ ├── components/ # React components │ │ ├── ui/ # ShadCN/UI components │ │ ├── chat/ # Chat interface components │ │ ├── notes/ # Note management components │ │ └── shared/ # Shared components │ ├── contexts/ # React contexts │ ├── hooks/ # Custom React hooks │ └── types/ # TypeScript type definitions ├── prisma/ # Database schema and migrations ├── docs/ # Comprehensive documentation ├── public/ # Static assets └── scripts/ # Build and utility scripts ``` ## Database Schema ### Core Models - **User**: User accounts with Supabase integration - **Note**: User knowledge base with vector embeddings - **Chat/Message**: Conversation history - **Document**: Uploaded files with extracted text - **Quiz/Flashcard**: Study tools - **UserMemory**: AI knowledge tracking system ### Key Relationships - User → Notes (one-to-many) - User → Chats (one-to-many) - Chat → Messages (one-to-many) - User → Documents (one-to-many) ## API Design ### Authentication - `GET/POST /auth/*` - Supabase Auth handlers - OAuth and email/password flows ### Core Features - `POST /api/chat` - AI tutoring conversations - `GET/POST/PUT/DELETE /api/notes` - Note management - `POST /api/documents` - Document upload and processing - `GET /api/search` - Semantic search across content - `GET/POST /api/user-memory` - Knowledge tracking ## Development Guidelines ### Code Style - Use outline variant for all buttons - Implement proper dark/light theme support - Follow academic integrity principles in AI responses - Use TypeScript for type safety - Implement proper error handling and loading states ### Security - Row Level Security (RLS) policies in Supabase - JWT token validation for API routes - Secure file upload handling - Input sanitization and validation ### Performance - Server-side rendering for SEO - Vector embeddings for fast semantic search - Optimized database queries with Prisma - Image optimization and lazy loading ## Environment Variables - `NEXT_PUBLIC_SUPABASE_URL` - Supabase project URL - `NEXT_PUBLIC_SUPABASE_ANON_KEY` - Supabase anonymous key - `SUPABASE_SERVICE_ROLE_KEY` - Supabase service role key - `OPENAI_API_KEY` - OpenAI API key - `DATABASE_URL` - PostgreSQL connection string ## Deployment - **Platform**: Vercel with serverless functions - **Database**: Supabase managed PostgreSQL - **Build Process**: Includes Prisma client generation - **Environment**: Production optimized with analytics ## Brand Guidelines - **Primary Color**: #1f1a14 (dark brown) - **Theme**: Dark/light mode support - **Typography**: Clean, academic-focused design - **Social**: @FennieAi (Twitter), @fennie.ai (Instagram) This codebase represents a production-ready SaaS application focused on ethical AI tutoring with comprehensive features for academic support while maintaining the highest standards of academic integrity.