How surjendu104/logsloth works
Project type and purpose
• LogSloth is a client-side, single-page application (SPA) built with React and TypeScript, bundled via Vite.
• Its purpose is privacy-first log analysis and visualization: users upload log files (Apache, Nginx, Gunicorn, etc.) and explore metrics entirely in their browser.
File structure
• Top-level:
• index.html, package.json, vite.config.ts – SPA entry and build config
• public/ – static assets and demo logs
• src/ – application source
• src/components/LogAnalysis – one directory per log-type, each containing:
– FileUpload.tsx / parser.ts / period.ts (ingestion & preprocessing)
– RawAccessLogViewer, RawErrorLogViewer (raw text)
– PiiDataLeakDetection, SuspeciousIPs, MalFormedRequests (analysis modules)
– Charts/ (a set of reusable chart components)
• src/context/LogContext.tsx & hooks/useLogContext.tsx – global state for parsed logs
• src/App.tsx & src/components/Header.tsx – top-level layout & navigation
• Config files: tsconfig, eslint.config.js, prettier, vercel.json – deployment and tooling.
README for additional insights
• Emphasizes client-only processing (“all processed completely on your machine”)
• Main features: file upload, instant exploration, dashboards.
a. Main components:
• Browser (Client)
• UI Layer (React Components)
• In-Browser Processing Engine
– File Upload Module
– Parser Modules (per log type)
– Period grouping & preprocessing
• Visualization Layer (Chart Components)
• State Management (LogContext)
• Static Hosting (Vercel/CDN)
b. Relationships & interactions:
1. User clicks “Upload” → FileUpload component reads file via FileReader API.
2. File contents passed to the correct parser.ts → produces structured records.
3. Period.ts groups records (e.g., by time intervals).
4. Parsed data stored in LogContext → accessible by any analysis & chart components.
5. Analysis modules (PiiDataLeakDetection, MalFormedRequests, etc.) consume context data and derive metrics.
6. Chart components subscribe to LogContext and render graphs.
7. Header & navigation components allow switching between log-type pages.
c. Architectural patterns & design principles:
• Component-based UI (React)
• Context API for state sharing (avoids prop drilling)
• Modular parser/analysis per log type (extensible pattern)
• Client-only, zero-trust model (no backend calls)
d. Key technologies:
• React + TypeScript + Vite
• Browser FileReader API
• CSS modules for styling
• Vercel for static deployment