How naman22a/solguardian works
Project type and purpose
• This is a full-stack web application called SolGuardian, whose purpose is to provide AI-powered, context-aware auditing of Solidity smart contracts.
• It offers a React/Next.js frontend, an Express backend that orchestrates static analysis + LLM reasoning (CodeLlama via Ollama/LangChain), and a separate worker process for heavy analysis tasks.
File structure
• Top-level split:
· client/ – Next.js 15 (App Router) TypeScript frontend, TailwindCSS, Shadcn UI, Zustand, socket.io-client, react-dropzone.
· server/ – Express 5 TypeScript API, Multer file uploads, socket.io for real-time, BullMQ queue, Redis, LangChain + CodeLlama integration, worker.ts for background processing.
· data/ – static datasets (vulnerabilities.json, CSV versions, training dataset) used by static analysis routines.
• Deployment / infra config: docker-compose.yml (spins up Redis), .env examples for config, tsconfig.json, build & run scripts in package.json.
README for additional insights
• Tech stack confirms components: Redis as cache/message broker, BullMQ queue, CodeLlama & LangChain modules, Ollama as local LLM host.
• There is no traditional RDBMS; intermediate data lives in Redis, local filesystem (uploads), and static JSON.
a. Main components:
1. Frontend (Next.js)
2. Backend API (Express server)
3. Redis (cache & BullMQ broker)
4. Worker process (BullMQ consumer)
5. AI Engine (Ollama-hosted CodeLlama accessed via LangChain)
6. Static Data Store (data/vulnerabilities.json, dataset CSVs)
7. File Storage (server/uploads)
8. External tools (Docker-Compose, environment config)
b. Relationships & interactions:
• User → Frontend: HTTP/HTTPS form upload and dashboard.
• Frontend → Backend:
• HTTP POST for file upload (/upload via Multer)
• socket.io for push-based processing status & final results
• Backend → Redis/BullMQ: enqueue audit job
• Worker → Redis/BullMQ: dequeue job
• Worker → AI Engine: send code snippets to CodeLlama through LangChain API calls
• Worker → Static Data: consult vulnerabilities.json and scoring heuristics
• Worker → Backend: push results back (e.g., via Redis events or direct socket.io emit)
• Backend → Frontend: deliver structured JSON report via socket.io or REST fetch
c. Architectural patterns & principles:
• Separation of concerns: UI vs API vs background processing
• Queue-based asynchronous processing (BullMQ + Redis)
• Pub/Sub for real-time updates (socket.io backed by Redis adapter if scaled)
• Local LLM invocation (Ollama) with thin API wrapper (LangChain)
• Static assets and configs managed alongside code
d. Key technologies highlighted:
• Next.js 15 + Turbopack, Zustand, Shadcn UI, TailwindCSS
• Express 5 (TS), Multer, Zod, Socket.io, BullMQ, ioredis
• LangChain (Community, Core, Ollama modules), CodeLlama, Ollama CLI
• Docker-Compose for Redis, pnpm monorepo tooling
• Rounded rectangles for services (Client, API, Worker).
• UI (blue), Backend (green), Processing (orange), Data (gray), External (purple).
Detail without overthinking
• Every data flow: from user file upload → job enqueue → LLM call → result deliver.
• Environment/config (Docker-Compose, .env) and static dataset sit on the side as supporting resources.