How genaiwithshubham/opennapkinai works
Project type and purpose
• This is a full-stack, monorepo web application (“OpenNapkinAI”) for converting user text into hand-drawn-style visuals.
• Frontend: React + Tailwind + Vite + EditorJS + RoughJS
• Backend: Express.js providing REST endpoints for AI integration and note management
• AI models: local Ollama or Anthropic Claude via Vercel AI SDK
• Shared code/config: TypeScript types, ESLint rules, tsconfig presets
File structure
• Top-level “apps” directory holds two apps:
• apps/backend – Express server with src/app.ts, src/routes/{ai.ts, notes.ts}, src/data/notes.ts
• “packages” directory holds reusable modules:
• types – shared TypeScript definitions (e.g. Note)
• eslint-config – centralized lint rules
• typescript-config – JSON presets for Node/Vite/React
• Turborepo configuration (turbo.json, .turbo/) orchestrates builds, caching, and parallel tasks
README for additional insights
• Key features: text-to-visual generation, CRUD for notes, choice of AI backends, hand-drawn style
• No external database: notes are stored via a lightweight data layer (in-memory or file)
• Env-based AI configuration (ANTHROPIC_API_KEY, OLLAMA_HOST, etc.)
Main components and their relationships
a. Frontend Web Client
• UI components (Editor, DiagramContainer, NoteCard, pages)
• Custom React hooks (useNoteQuery, useCreateNoteMutation, useNotesQuery, etc.)
• Renders AI response with RoughJS via DiagramRenderer
b. Backend API Server
• Express app with two route groups:
• /routes/notes.ts – CRUD operations using src/data/notes.ts
• /routes/ai.ts – Orchestrates AI calls (local Ollama or Anthropic)
• Middleware, error handling, environment configuration
c. AI Model Services (External)
• Ollama local host or Anthropic remote service
d. Shared Packages
• eslint-config & typescript-config: maintain coding standards and TS compiler settings
e. Scripts & Build Tools
• Python scripts for theme-building or converting sketches
• Turborepo to coordinate build/test across all modules
Important architectural patterns and principles
• Monorepo structure (Turborepo) for code sharing and unified CI/CD
• Clear separation of concerns (UI vs. API vs. AI integration vs. shared types)
• Component-based UI with custom hooks for data fetching
• Route-based modular backend
• Environment-driven configuration for pluggable AI providers
• Shared TypeScript definitions to avoid drift
Key details not to miss
• Monorepo orchestration (Turborepo caching/build tasks) at the top level
• Shared TypeScript types enforcing contract between frontend and backend
• Pluggable AI provider layer abstracted in routes/ai.ts