A cutting-edge full-stack application that performs comprehensive lexical analysis on C++ and Java source code with AI-powered insights. Built with React (frontend) and FastAPI (backend), featuring a beautiful, modern interface with advanced code analysis capabilities powered by Google Gemini AI.
- Gemini AI Integration: Intelligent code quality assessment
- Code Quality Scoring: 1-10 quality rating with detailed feedback
- Bug Detection: Automatic identification of potential issues
- Performance Suggestions: AI-recommended optimizations
- Security Analysis: Vulnerability detection and security recommendations
- Best Practices: Code style and convention suggestions
- C++ to Java: AI-powered language conversion
- Java to C++: Intelligent cross-language translation
- Syntax Preservation: Maintains functionality while adapting syntax
- Convention Adherence: Follows target language best practices
- Cyclomatic Complexity: Code complexity measurement
- Function Count: Automatic function/method detection
- Comment Density: Documentation quality metrics
- Token Distribution: Visual analysis of code composition
- Operator Frequency: Usage pattern analysis
- Monaco Editor: Professional code editor with syntax highlighting
- Interactive Charts: Recharts-powered data visualization
- Smooth Animations: Framer Motion for delightful interactions
- Responsive Design: Works perfectly on all devices
- Dark/Light Themes: Beautiful gradient themes
- Real-time Feedback: Instant analysis results
- Syntax Error Detection: Automatic error identification
- Symbol Table: Comprehensive token categorization
- Export Functionality: PDF reports with charts and insights
- Multiple Input Methods: File upload, code paste, drag-and-drop
- Live Code Editor: Real-time editing with analysis
β
Whitespace Removal - Cleans and normalizes code
β
Comment Removal - Strips single-line (//) and multi-line (/* */) comments
β
Constant Recognition - Identifies integers, floats, strings, characters, and booleans
β
Keyword Recognition - Detects all C++ and Java language keywords
β
Identifier Recognition - Extracts all variable and function names
β
Operator Recognition - Identifies all operators with usage statistics
β
Symbol Table - Generates comprehensive symbol table with token types and counts
- FastAPI - Modern Python web framework
- Google Gemini AI - Advanced language model integration
- Pydantic - Data validation and serialization
- ReportLab - PDF generation
- Matplotlib/Seaborn - Data visualization
- Plotly - Interactive charts
- React 18 - Modern UI library with hooks
- Monaco Editor - Professional code editor
- Recharts - Data visualization library
- Framer Motion - Smooth animations
- Tailwind CSS - Utility-first styling
- React Hot Toast - Beautiful notifications
- React Icons - Comprehensive icon library
- Python 3.8+
- Node.js 14+
- Gemini API Key (optional, for AI features)
git clone <repository-url>
cd CC-Assignmentcd backend
# Create virtual environment
python -m venv venv
# Activate virtual environment
# Windows:
.\venv\Scripts\activate
# Mac/Linux:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Set up Gemini API key (optional)
# Create .env file with:
# GEMINI_API_KEY=your-api-key-here
# Start backend
python main.pycd frontend
# Install dependencies
npm install
# Start frontend
npm startOpen your browser and go to: http://localhost:3000
For AI-powered features, you'll need a Gemini API key:
- Visit Google AI Studio
- Create an API key
- Add it to
backend/.env:GEMINI_API_KEY=your-actual-api-key-here - Restart the backend
See GEMINI_SETUP.md for detailed instructions.
- Upload File: Drag & drop or click to upload .cpp/.java files
- Paste Code: Use the Monaco editor to write/paste code
- Select Language: Choose C++ or Java
- Click "Basic Analysis": Get comprehensive lexical analysis
- Enter Code: Use the code editor or upload a file
- Click "AI Analysis": Get AI-powered insights and recommendations
- View Results: Check the "AI Insights" tab for detailed feedback
- Go to "Translate" Tab: Switch to translation mode
- Select Languages: Choose source and target languages
- Enter Code: Paste the code to translate
- Click "Translate": Get AI-translated code
- Analyze Code: Complete any analysis
- Click "Export PDF": Generate comprehensive report
- Download: Get PDF with charts, statistics, and insights
- File Upload: Drag-and-drop or click to browse
- Code Editor: Monaco editor with syntax highlighting
- Language Selection: C++ or Java support
- Sample Code: Pre-loaded examples for testing
- Basic Analysis: Lexical analysis with token extraction
- Advanced Analysis: AI-powered insights and error detection
- Translation: Cross-language code conversion
- Export: PDF reports with visualizations
- Overview: Quick summary with key metrics
- Complexity: Cyclomatic complexity and function analysis
- AI Insights: Gemini-powered code review
- Error Detection: Syntax error identification
- Charts: Interactive data visualizations
- Symbol Table: Comprehensive token categorization
- Cleaned Code: Code without comments/whitespace
- Gradient Themes: Beautiful color schemes
- Smooth Animations: Framer Motion transitions
- Responsive Layout: Works on all screen sizes
- Interactive Elements: Hover effects and micro-interactions
- Monaco Editor: VS Code-like editing experience
- Syntax Highlighting: Language-specific coloring
- Auto-completion: Intelligent code suggestions
- Bracket Matching: Visual bracket pairing
- Line Numbers: Professional code display
- Pie Charts: Token distribution analysis
- Bar Charts: Operator frequency graphs
- Interactive Tooltips: Detailed information on hover
- Responsive Charts: Adapts to screen size
POST /analyze- Basic file analysisPOST /analyze-code- Basic code analysisPOST /analyze-advanced- AI-powered analysis
POST /translate- Code translationPOST /export-pdf- PDF report generation
GET /docs- Interactive API documentation (Swagger)GET /redoc- Alternative API documentation
# Backend (.env)
GEMINI_API_KEY=your-gemini-api-key
PORT=8000
# Frontend
REACT_APP_API_URL=http://localhost:8000- Colors: Modify Tailwind config for custom themes
- Charts: Customize Recharts components
- AI Prompts: Adjust Gemini prompts in backend
- Analysis Rules: Modify regex patterns for token detection
- Backend won't start: Check Python version and dependencies
- Frontend won't start: Verify Node.js version and npm install
- AI features not working: Check Gemini API key configuration
- CORS errors: Ensure backend is running on correct port
- Backend: Check console logs for detailed error messages
- Frontend: Open browser DevTools for client-side errors
- API: Use
/docsendpoint for interactive testing
- Small files (<100 lines): < 0.5 seconds
- Medium files (100-1000 lines): 0.5-2 seconds
- Large files (1000-5000 lines): 2-5 seconds
- AI Analysis: Additional 2-5 seconds (depends on API response)
- Caching: Results cached for repeated analysis
- Lazy Loading: Components loaded on demand
- Code Splitting: Optimized bundle sizes
- Image Optimization: Compressed assets
- Local Processing: All analysis done on your machine
- No Data Storage: Code not saved or logged
- API Security: Secure communication with Gemini
- Input Validation: Sanitized user inputs
- Environment Variables: API keys not in code
- HTTPS: Secure communication in production
- Rate Limiting: API usage monitoring
- Error Handling: Graceful failure management
- Support for more languages (Python, JavaScript, C#)
- Advanced syntax highlighting themes
- Code comparison and diff analysis
- Team collaboration features
- Integration with version control systems
- Custom analysis rules
- Batch file processing
- Real-time collaboration
- Custom AI model training
- Advanced code generation
- Automated refactoring suggestions
- Code documentation generation
- Test case generation
This project is open source and available under the MIT License.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
- Documentation: Check this README and setup guides
- Issues: Open GitHub issues for bugs or feature requests
- Discussions: Use GitHub Discussions for questions
- Email: Contact maintainers for urgent issues
Built with β€οΈ using React, FastAPI, and Google Gemini AI By Ahmad Bajwa
Transform your code analysis experience with AI-powered insights! π