How ritik-gusain/indentron works
Project Type & Purpose
• Full-stack web application: a single-page front-end (public/index.html + vanilla JS) served by a Node.js/Express backend.
• Purpose: real-time code formatting across 12+ languages, plus code sharing and analytics.
High-Level Components
a. Client/UI Layer
• Browser running the static HTML/JS/CSS in public/
• Glassmorphic editor UI, language dropdown, format/share buttons
b. Server/API Layer (Express)
• server.js (entry point)
• Routes (src/routes/*)
• Middleware (src/middleware/*)
• Controllers (src/controllers/*)
• Services (src/services/*, including AIFormatterService, FormatterService, ShareService, AnalyticsService)
• Formatters (src/services/formatters/*.js)
• Utils (src/utils/logger.js, formatUtils.js)
• Config (config/config.js, config/ai-config.js)
c. External Services
• OpenAI API (for advanced formatting)
• Vercel (static + serverless hosting)
• (Optional) In-memory or file-based store for shared code
Data Flow & Interactions
• User action in browser → HTTP request to Express (e.g., POST /format)
• Request passes through rateLimiter & validation middleware
• Route handler (formatRoutes.js) dispatches to FormatController
• FormatController invokes AIFormatterService or FormatterService
– FormatterService delegates to language-specific formatter modules
– AIFormatterService calls OpenAI API, applies ai-config settings
• Controller assembles response → sends JSON back to UI
• AnalyticsService logs usage (could POST to external or write locally)
• For sharing: ShareController ↔ ShareService → persist share record → return share ID
Architectural Patterns & Principles
• MVC (Routes → Controllers → Services → Views/Responses)
• Modular organization: one folder per concern (routes, controllers, services, utils)
• Single responsibility: each formatter module handles one language
• Centralized configuration & environment management (config/)
Detail Level
• Do not collapse too aggressively: the value is in illustrating each moving part (controllers vs. services vs. utils).
• Config files and environment variables (PORT, OPENAI_API_KEY) are called out.