How vartikajn07/codeslate works
Project type and purpose
• Codeslate is a full-stack, React-based web application built with Next.js 14.
• Its core purpose is to let users write or paste code, customize its appearance (theme, fonts, padding, backgrounds), and export/share high-quality snippet images.
File structure
• Top-level Next.js directories:
• app/ – Next.js App Router pages (layout.tsx, page.tsx) and global CSS
• public/ – static assets (fonts, videos, JSON)
• components/ & components/ui/ – reusable React UI components (shadcn/ui wrappers)
• hooks/ – custom React hooks (useToast, useDarkmode)
• store/ – Zustand global state (canvasStore.ts)
• services/ – API clients (supabaseClient.ts, imageService.ts)
• utils/ & lib/ – helper functions (supabaseUpload, utilities, utils.ts)
• config files: next.config.js, tsconfig.json, tailwind.config.ts, postcss.config.mjs
Key insights from the README
• Tech Stack: Next.js 14, TypeScript, Tailwind, shadcn/ui, Zustand, Supabase, Unsplash, Framer Motion
• Features: live code editor, theme selectors, background fetch (Unsplash), PNG export via html2canvas, upload to Supabase, shareable links
Main components and their relationships
a. Frontend (Client Browser)
• Renders pages & components (CodeEditor, ThemeSelector, etc.)
• Maintains UI state via Zustand (store/canvasStore.ts)
• Uses custom hooks (useToast, useDarkmode) for notifications and theme persistence
• Invokes html2canvas or imageService to generate PNG snapshots
b. Next.js Runtime (Server/Edge)
• Serves the React app, handles SSR/SSG if any, and environment variables
c. External Services
1. Unsplash API (via imageService.ts) – fetches random backgrounds
2. Supabase Storage (via supabaseClient.ts & supabaseUpload) – uploads generated images, returns shareable URLs
d. Utilities & Styling
• Tailwind CSS (tailwind.config.ts) for styling
• shadcn/ui components for dialogs, sliders, buttons
• Global CSS (app/globals.css) for base styles
Architectural patterns and design principles
• Component-based UI (React/Next.js with App Router)
• Single Page Application behavior for interactivity
• Global state management with Zustand for theme & canvas settings
• Separation of concerns: UI components ←→ services ←→ external APIs
• Utility modules for reusability (utils, lib)