How sai-pratham05/code-shimasu works
Project Type and Purpose
• This is a full-stack web application called “code-shimasu,” built with Next.js (App Router) and TypeScript on the front end, and Convex on the back end.
• Purpose: collaborative code authoring, execution, sharing, and user-profile management with real-time features, multi-language support, and payment integration for premium plans.
File Structure Analysis
• Top level:
• convex/ – backend logic: Convex schema, serverless functions (codeExecutions.ts, snippets.ts, users.ts), authentication (auth.config.ts), external-service integrations (lemonSqueezy.ts, http.ts).
• src/app/ – Next.js App Router pages and layouts, organized by route: root, pricing, profile, snippets/[id].
• src/components/ – shared UI components and providers (ConvexClientProvider).
• Tailwind & PostCSS configs, ESLint, TS configs, package.json, next.config.ts.
• Architectural hints:
• Front end is a React/Next.js single-page interface with server-side and client-side rendering.
• Backend uses Convex as a serverless platform for data storage, function execution, and real-time subscriptions.
• External services for code sandboxing (via HTTP calls in codeExecutions.ts) and payment (LemonSqueezy).
Key Insights from README
• Real-time collaboration, snippet sharing via unique links.
• Multi-language execution in “secure, isolated environments.”
• User profiles and authentication.
• Payment for premium via LemonSqueezy.
Components
a. Frontend (Browser)
• Next.js App – pages, components, client-side state (Zustand or similar store).
• Convex Client SDK for data queries/mutations and real-time subscriptions.
• UI modules: EditorPanel, OutputPanel, LanguageSelector, RunButton, ShareSnippetDialog.
b. Backend
• Next.js Server (hosted on Vercel/Node) – handles SSR/SSG, API routes (if any), static asset serving.
• Convex Serverless Functions – codeExecutions, snippets CRUD, users, auth workflows.
c. Database
• Convex Database – stores users, snippets, comments, execution results, subscription data.
d. External Services
• Code Execution Sandbox – isolated environment for running user code (invoked via HTTP from Convex).
• LemonSqueezy – payment processing integration for premium feature gating.
• (Optional) Auth Provider – if not custom, via Convex auth or OAuth endpoints.
e. Static Assets
• CDN/Static Storage – hosts images, CSS (Tailwind), fonts.
Relationships and Data Flows
• User → Browser (React)
• Choose language, write code.
• Click Run → ConvexClient → codeExecutions function → Code Execution Service → return output.
• Click Share → ConvexClient → snippets.create → return snippet ID → shareable URL.
• Authentication flows → Convex Auth functions → set session cookie.
• Browser → Next.js Server
• Initial page load SSR/SSG, static route serving.
• API calls for data not handled by Convex SDK (if any).
• Convex Serverless → Convex DB
• Queries, mutations, real-time subscriptions on snippet/comment/user collections.
• Convex Serverless → External Services
• HTTP calls to LemonSqueezy for payment checks, Code Execution Service for sandbox runs.
Architectural Patterns and Principles
• Separation of concerns: UI layer (React/Next.js) vs data/business logic (Convex).
• Serverless microservices (Convex functions) for scalability and real-time subscriptions.
• Single source of truth: Convex database with real-time change feeds.
• Externalized services for specialized tasks (code sandboxing, payments).