How whats-up-pro/nt547 works
Project Type and Purpose
• This is a full-stack web application: a Control Flow Graph (CFG) visualizer for Solidity smart contracts.
• Purpose: Users paste Solidity code into a web editor, the system parses the code into an AST, constructs a CFG, and renders it interactively for security analysis and comprehension.
File Structure Analysis
Top-level:
• backend/ (Python Flask service, plus a Node helper)
• frontend/ (React app)
• documentation and setup guides (.md files)
• test_contracts.js (sample inputs)
backend/:
• app.py – Flask entry point; defines REST routes (health checks, analysis endpoints)
• api/routes.py – Flask route definitions
• security_analyzer.py – placeholder for server-side security logic
• node_helper/ – Node.js microservice (index.js) for AST or supplemental parsing tasks
• requirements.txt – Python dependencies
frontend/:
• public/index.html – host HTML page
• src/index.js, App.js – React bootstrapping and main component
• src/components/CodeEditor.js – Monaco code editor wrapper
• src/components/CFGVisualizer.js – React Flow graph renderer
• src/utils/parser.js – AST parsing and CFG-builder logic using @solidity-parser/parser
• package.json – React and tool dependencies
README Insights
• Architecture is explicitly two-tier: React frontend and Flask backend with CORS enabled.
• Frontend handles AST parsing and CFG construction via @solidity-parser/parser and React Flow.
• Backend currently only provides health checks, but is extensible (e.g., to offload parsing or security analysis).
• No database layer; interactions are ephemeral.
a. Main Components
1. Client Browser (User Agent)
2. React Frontend
• CodeEditor (Monaco)
• CFGBuilder & Parser (utils/parser.js)
• Visualization Engine (React Flow)
3. Backend Services
• Flask REST API (app.py, api/routes.py)
• SecurityAnalyzer (security_analyzer.py)
• NodeHelper Microservice (node_helper/index.js)
4. External Libraries/Services
• @solidity-parser/parser (JavaScript AST parser)
• React Flow (graph lib)
• Monaco Editor
• Flask-CORS
• Axios (HTTP client)
b. Relationships & Data Flows
• User → React App (code input)
• React App → Parser/CFGBuilder (AST & graph model)
• React App ↔ Flask API (health checks, future server analysis) via Axios
• Flask API → NodeHelper (spawn JS process for AST or heavy jobs)
• NodeHelper → Flask API (returns parse results)
• React App → React Flow (renders CFG)
• User ↔ React Flow (interactive node clicks → highlight code)
c. Architectural Patterns & Principles
• Two-tier client-server separation
• Modular frontend: editor, parser, visualizer
• Microservice pattern for Node-based parsing helper
• RESTful API layer with CORS
• Separation of concerns: UI vs. processing vs. data models
d. Key Technologies & Libraries
• Frontend: React18, Monaco Editor, @solidity-parser/parser, React Flow, Axios
• Backend: Python3.8+, Flask, Flask-CORS, Node.js (for node_helper)