Skip to content

MohitGoyal09/MemexLLM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

44 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MemexLLM Frontend

MemexLLM Logo

Modern React Frontend for AI-Powered Document Intelligence

Next.js TypeScript Tailwind CSS License: MIT

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


🎯 Overview

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.


πŸ›οΈ Architecture

MemexLLM Frontend Architecture

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)                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Architectural Patterns

  • 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.


✨ Features

  • 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

πŸ› οΈ Tech Stack

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

πŸš€ Quick Start

Prerequisites

  • Node.js 18+
  • pnpm (recommended) or npm
  • Backend API running

Installation

cd frontend
pnpm install

Environment Setup

Create .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-key

Development

pnpm dev

Open http://localhost:3000


πŸ“ Project Structure

frontend/
β”œβ”€β”€ 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

πŸ“š Documentation

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

πŸ“ Available Scripts

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

πŸ”‘ Key Components

ChatPanel

Main chat interface with streaming support, citations, and suggested questions.

SourcesPanel

Document management with upload, status tracking, and preview.

NotesPanel

Rich text notes with auto-save using TipTap editor.

StudioPanel

AI content generation interface for podcasts, quizzes, flashcards, and mindmaps.


πŸ”Œ API Integration

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)
);

πŸ” Authentication

Uses Supabase Auth with cookie-based sessions:

import { createClient } from "@/lib/supabase/client";

const supabase = createClient();
const { data: { session } } = await supabase.auth.getSession();

🎨 Styling

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 */

🌍 Environment Variables

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

🚒 Deployment

Vercel (Recommended)

  1. Push to GitHub
  2. Import project in Vercel
  3. Add environment variables
  4. Deploy

Docker

FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]

🀝 Contributing

  1. Follow the existing code style
  2. Use TypeScript strict mode
  3. Write tests for new features
  4. Update documentation

See CONTRIBUTING.md for details.


πŸ“œ License

MIT License

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors