Modern React Frontend for AI-Powered Document Intelligence
Next.js 14 application with TypeScript, Tailwind CSS, and shadcn/ui for the MemexLLM AI research assistant.
Backend Repo β’ Features β’ Architecture β’ Tech Stack β’ Quick Start β’ Documentation β’ Deployment
The frontend provides a modern, responsive interface for interacting with the MemexLLM backend. It supports document upload, AI-powered chat with citations, content generation, and notebook management.
Built for production with server-side rendering, real-time streaming, and enterprise-grade authentication.
The frontend follows a layered architecture with clear separation of concerns:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β User Interface β
β (Landing, Home, Notebook Pages) β
ββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Component Layer β
β (Chat Panel, Sources Panel, Studio Panel, etc.) β
ββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Hooks Layer β
β (useNotes, useStudio, useChat, etc.) β
ββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β API Client Layer β
β (notebooksApi, chatApi, documentsApi, etc.) β
ββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Backend API (FastAPI) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Server Components: Default Next.js 14 App Router pattern for optimal performance
- Client Components: Interactive UI components with React hooks
- Custom Hooks: Reusable stateful logic (useNotes, useStudio, useChat)
- API Client Pattern: Type-safe REST API integration with SSE streaming
- Authentication: JWT-based auth with Supabase Auth SSR support
See docs/ARCHITECTURE.md for detailed architecture documentation.
- Authentication: Supabase Auth with SSR support
- Document Management: Upload and manage research documents (PDF, TXT, DOCX, audio, YouTube, web pages)
- AI Chat: Contextual Q&A with source citations and streaming responses
- Content Generation: Create podcasts, quizzes, flashcards, and mindmaps from documents
- Notebook Organization: Organize research into notebooks with chat history and notes
- Real-time: Server-Sent Events (SSE) for streaming chat responses
- Responsive: Mobile-first design with dark/light mode
| Category | Technology |
|---|---|
| Framework | Next.js 14 (App Router) |
| Language | TypeScript |
| Styling | Tailwind CSS |
| Components | shadcn/ui |
| State | React hooks + Context |
| Auth | Supabase Auth |
| API | REST + Server-Sent Events |
| Testing | Jest + React Testing Library |
| Analytics | PostHog + Sentry |
- Node.js 18+
- pnpm (recommended) or npm
- Backend API running
cd frontend
pnpm installCreate .env.local:
# Required
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=your-anon-key
NEXT_PUBLIC_API_URL=http://localhost:8000
# Optional
NEXT_PUBLIC_APP_URL=http://localhost:3000
NEXT_PUBLIC_SENTRY_DSN=your-sentry-dsn
NEXT_PUBLIC_POSTHOG_KEY=your-posthog-keypnpm devfrontend/
βββ app/ # Next.js App Router
β βββ auth/ # Authentication pages (login, signup, etc.)
β βββ home/ # Home/dashboard page
β βββ notebook/ # Notebook workspace pages
β βββ settings/ # User settings page
β βββ layout.tsx # Root layout with providers
β βββ page.tsx # Landing page
β βββ globals.css # Global styles
βββ components/ # React components
β βββ ui/ # shadcn/ui components
β βββ landing/ # Landing page sections
β βββ chat-panel.tsx # Main chat interface
β βββ sources-panel.tsx # Document sources panel
β βββ notes-panel.tsx # Notes management
β βββ studio-panel.tsx # Content generation
β βββ ...
βββ hooks/ # Custom React hooks
β βββ use-notes.ts # Notes CRUD + auto-save
β βββ use-studio.ts # Content generation
β βββ use-suggested-questions.ts
βββ lib/ # Utilities and API
β βββ api/ # API clients
β β βββ client.ts # Base HTTP client
β β βββ types.ts # API types
β β βββ notebooks.ts
β β βββ chat.ts
β β βββ documents.ts
β β βββ ...
β βββ supabase/ # Supabase clients
β βββ analytics/ # Analytics providers
β βββ types.ts # Shared types
β βββ utils.ts # Utilities
βββ public/ # Static assets
βββ docs/ # Documentation
βββ __tests__/ # Test files
See the docs/ directory for detailed documentation:
| Document | Description |
|---|---|
| Architecture | System design, data flows, and architectural patterns |
| API Client | Backend API integration |
| Components | UI components documentation |
| Configuration | Environment variables and setup |
| Hooks | Custom React hooks |
| Types | TypeScript type definitions |
| Command | Description |
|---|---|
pnpm dev |
Start development server |
pnpm build |
Build for production |
pnpm start |
Start production server |
pnpm lint |
Run ESLint |
pnpm test |
Run tests |
pnpm test:watch |
Run tests in watch mode |
pnpm test:coverage |
Run tests with coverage |
Main chat interface with streaming support, citations, and suggested questions.
Document management with upload, status tracking, and preview.
Rich text notes with auto-save using TipTap editor.
AI content generation interface for podcasts, quizzes, flashcards, and mindmaps.
The frontend communicates with the backend via REST API and Server-Sent Events:
import { chatApi } from "@/lib/api";
// Send message with streaming
await chatApi.sendMessageStream(
notebookId,
"What is this document about?",
(token) => setMessage(prev => prev + token),
(citations) => setCitations(citations),
() => setIsStreaming(false)
);Uses Supabase Auth with cookie-based sessions:
import { createClient } from "@/lib/supabase/client";
const supabase = createClient();
const { data: { session } } = await supabase.auth.getSession();Uses Tailwind CSS with custom brand colors:
/* Primary brand color */
.bg-synapse-500 /* #ff8200 */
/* Surface colors for dark theme */
.bg-surface-0 /* #0a0a0a */
.bg-surface-1 /* #141414 */| Variable | Required | Description |
|---|---|---|
NEXT_PUBLIC_SUPABASE_URL |
Yes | Supabase project URL |
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY |
Yes | Supabase anon key |
NEXT_PUBLIC_API_URL |
Yes | Backend API URL |
NEXT_PUBLIC_APP_URL |
No | Frontend app URL |
NEXT_PUBLIC_SENTRY_DSN |
No | Sentry error tracking |
NEXT_PUBLIC_POSTHOG_KEY |
No | PostHog analytics |
- Push to GitHub
- Import project in Vercel
- Add environment variables
- Deploy
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]- Follow the existing code style
- Use TypeScript strict mode
- Write tests for new features
- Update documentation
See CONTRIBUTING.md for details.
MIT License
