Codalyze is a web-based C++ static code analyzer that estimates Time Complexity, Space Complexity, detects STL containers, STL algorithms, recursion, and provides optimization suggestions using Tree-sitter Abstract Syntax Trees (AST).
๐ Live Demo: https://codalyze-two.vercel.app/
- ๐ Estimates overall Time Complexity
- ๐พ Estimates Auxiliary Space Complexity
- ๐ Detects loops and nested loops
- ๐ Detects recursive functions
- ๐ Detects STL Containers
- vector
- map
- unordered_map
- set
- unordered_set
- queue
- stack
- priority_queue
- โก Detects common STL Algorithms
- sort()
- stable_sort()
- reverse()
- binary_search()
- lower_bound()
- upper_bound()
- nth_element()
- ๐ Generates Complexity Timeline
- ๐ก Provides Optimization Suggestions
- ๐จ Clean and Interactive UI
- ๐ Fully Deployed (Frontend + Backend)
- HTML5
- CSS3
- JavaScript
- Node.js
- Express.js
- Tree-sitter
- tree-sitter-cpp
- Frontend: Vercel
- Backend: Render
Codalyze
โ
โโโ backend
โ โโโ analyzer
โ โ โโโ database
โ โ โโโ visitors
โ โ โโโ cppAnalyzer.js
โ โ โโโ complexityCalculator.js
โ โ โโโ optimizationEngine.js
โ โ โโโ timelineGenerator.js
โ โ โโโ treeWalker.js
โ โ
โ โโโ server.js
โ โโโ package.json
โ
โโโ index.html
โโโ script.js
โโโ style.css
โ
โโโ timeReport.html
โโโ timeReport.js
โ
โโโ spaceReport.html
โโโ spaceReport.js
โ
โโโ optimization.html
โโโ optimization.js
โ
โโโ README.md
- User writes or pastes C++ code.
- Frontend sends the code to the Express backend.
- Tree-sitter parses the source code into an Abstract Syntax Tree (AST).
- Visitors traverse the AST to detect:
- loops
- recursion
- STL containers
- STL algorithms
- function calls
- Complexity Engine estimates:
- Time Complexity
- Space Complexity
- Optimization Engine generates suggestions.
- Results are returned as JSON and displayed in interactive reports.
- for
- while
- do-while
- nested loops
- Direct recursion
- vector
- map
- unordered_map
- set
- unordered_set
- queue
- stack
- priority_queue
- sort
- stable_sort
- reverse
- binary_search
- lower_bound
- upper_bound
- nth_element
Overall : O(n log n)
Worst Case : O(n log n)
Average Case : O(n log n)
Best Case : O(log n)
Overall : O(n)
Example suggestions include:
- Reduce Nested Loops
- Reserve Vector Capacity
- Check Sorting Necessity
- Consider unordered_map instead of map
- Avoid Deep Recursion
git clone https://github.com/YOUR_USERNAME/Codalyze.gitcd backend
npm installnpm startServer runs on
http://localhost:5000
Open
index.html
using Live Server or any static web server.
Hosted on Vercel
Hosted on Render
Codalyze is designed to accurately analyze many common competitive programming and interview-style C++ programs.
It currently focuses on:
- Loop analysis
- Nested loops
- STL algorithm detection
- STL container detection
- Recursive functions
- Basic complexity estimation
- Support for Graph algorithms
- Dynamic Programming detection
- Greedy algorithm recognition
- Binary Search pattern detection
- DFS/BFS recognition
- Segment Tree detection
- Fenwick Tree detection
- Better recursion depth estimation
- Multi-file project support
- Additional programming languages
Contributions are welcome.
If you find bugs or have ideas for improvements, feel free to open an Issue or submit a Pull Request.
Ali Khan
GitHub:
https://github.com/Ali-khan-786
Give this repository a โญ on GitHub.
It helps others discover the project and motivates future improvements.