OpenCrates: AI-Powered Rust Development Companion
OpenCrates is a comprehensive, AI-powered toolkit designed to accelerate Rust development by offering intelligent crate generation, project analysis, and advanced code assistance. It is built for professional developers who value efficiency, best practices, and robust tooling.
Features
- Intelligent Crate Generation: Create new Rust crates from templates with AI-assisted configuration and dependency selection.
- Advanced Project Analysis: Perform comprehensive analysis of existing projects to identify dependencies, check for vulnerabilities, and suggest improvements.
- AI-Powered Code Assistance: Leverage OpenAI's GPT models for code completion, refactoring, and optimization suggestions.
- Interactive TUI Dashboard: Manage projects, view analysis results, and interact with AI features through a terminal-based user interface.
- Extensible Agent System: Utilize a flexible agent system for custom automated workflows and integrations.
- Comprehensive Caching: Speed up operations with a multi-layer caching system supporting both in-memory and Redis backends.
- Web Server and API: Expose OpenCrates' functionality through a FastAPI-based web server with a full REST API.
- Metrics and Health Monitoring: Monitor application performance and health with Prometheus-compatible metrics and health check endpoints.
System Requirements
- Rust (1.70 or newer)
- Docker & Docker Compose (for containerized deployment)
- An active OpenAI API key
Quick Start
1. Installation
Clone the repository and build the project:
2. Environment Configuration
Export your OpenAI API key as an environment variable:
3. Verify Installation
Run the test suite to ensure all components are functioning correctly:
Usage
OpenCrates provides a powerful command-line interface (CLI) for all its features.
Initialize a Project
# Initialize a new project in the current directory
# Initialize in a specific directory
Generate a Crate
Analyze a Project
# Analyze the current project and get AI recommendations
Start the Web Server
Once running, the API is available at http://127.0.0.1:8080.
Docker Deployment
For a containerized setup, use the provided Docker and Docker Compose configurations.
Build the Docker Image
Run with Docker Compose
This will start the OpenCrates application server and a Redis instance for caching.
Development
Running Tests
# Run all tests
# Run only integration tests
Code Formatting and Linting
This project uses rustfmt for formatting and clippy for linting.
Generating Documentation
This will build and open the project documentation in your web browser.
Configuration
OpenCrates can be configured through various methods:
Environment Variables
Configuration File
Create opencrates.toml:
[]
= "0.0.0.0"
= 8080
= 4
[]
= "openai"
= "gpt-4o"
= 4096
= 0.7
[]
= "sqlite:opencrates.db"
= 10
[]
= "memory"
= 3600
API Reference
FastAPI Endpoints
Health & Monitoring
GET /health- System health checkGET /health/detailed- Detailed health informationGET /metrics- Prometheus metricsGET /status- System status
Core Operations
POST /api/generate- Generate new cratePOST /api/search- Search cratesGET /api/crates/{name}- Get crate informationPOST /api/analyze- Analyze project
Configuration
GET /config- Get application configurationPOST /config- Update configuration
WebSocket Events
- Real-time project updates
- Build status notifications
- AI agent communications
Architecture
System Components
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ CLI │ │ TUI │ │ FastAPI │
│ Interface │ │ Dashboard │ │ Server │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
└───────────────────────┼───────────────────────┘
│
┌─────────────────────────────────────────────────┐
│ Core Engine │
├─────────────────────────────────────────────────┤
│ • Project Analysis • Template Management │
│ • Code Generation • Metrics Collection │
│ • AI Integration • Health Monitoring │
└─────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────┐
│ AI Agents Layer │
├─────────────────────────────────────────────────┤
│ • Crate Generator • Code Reviewer │
│ • Project Analyzer • Optimizer │
│ • Search Agent • Chat Assistant │
└─────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────┐
│ External Services │
├─────────────────────────────────────────────────┤
│ • OpenAI API • Crates.io Registry │
│ • GitHub API • Docker Registry │
│ • Search Providers • Documentation APIs │
└─────────────────────────────────────────────────┘
Data Flow
- Input Processing: CLI/TUI/API receives user requests
- Context Analysis: Core engine analyzes project context
- AI Processing: Agents process requests with AI models
- Output Generation: Results formatted and returned
- Monitoring: Metrics and health data collected
Testing
Comprehensive Testing Suite
# Run all tests
# Individual test categories
Test Coverage
- Unit Tests: 95%+ coverage of core functionality
- Integration Tests: End-to-end workflow validation
- Performance Tests: Benchmark and load testing
- Security Tests: Vulnerability scanning and audit
Continuous Integration
- Automated testing on push/PR
- Security vulnerability scanning
- Performance regression detection
- Documentation generation
Performance
Benchmarks
- Code Generation: < 2s for typical crates
- Project Analysis: < 5s for medium projects
- API Response Time: < 100ms for most endpoints
- Memory Usage: < 50MB baseline usage
- Startup Time: < 1s cold start
Optimization Features
- Intelligent caching strategies
- Lazy loading of AI models
- Concurrent processing
- Memory-efficient data structures
- Optimized database queries
Development
Contributing
- Fork the repository
- Create a feature branch
- Implement your changes
- Add comprehensive tests
- Submit a pull request
Development Setup
# Clone and setup
# Install development dependencies
# Run in development mode
# Run with file watching
Code Style
- Follow Rust standard formatting (
cargo fmt) - Pass all Clippy lints (
cargo clippy) - Maintain test coverage above 90%
- Document all public APIs
Security
Security Features
- API key encryption and secure storage
- Input validation and sanitization
- Rate limiting and DDoS protection
- Secure dependency management
- Regular security audits
Vulnerability Management
- Automated dependency scanning
- Security advisory monitoring
- Regular penetration testing
- Responsible disclosure policy
Roadmap
Current Version (v0.1.1)
- ✅ Core CLI functionality
- ✅ AI integration with OpenAI
- ✅ Basic project analysis
- ✅ TUI dashboard
- ✅ FastAPI server
- ✅ Docker containerization
Upcoming Features
- 🔄 Advanced code refactoring
- 🔄 Multi-language support
- 🔄 Plugin architecture
- 🔄 Cloud deployment options
- 🔄 Team collaboration features
Future Vision
- 🚀 Visual Studio Code extension
- 🚀 GitHub Actions integration
- 🚀 Advanced ML models
- 🚀 Enterprise features
- 🚀 SaaS offering
Support
Documentation
- API Documentation: Available at
/docswhen server is running - User Guide: Comprehensive usage examples
- Developer Guide: Architecture and contribution guidelines
Community
- GitHub Issues: Bug reports and feature requests
- Discussions: Community Q&A and ideas
- Discord: Real-time community chat
Professional Support
- Enterprise Support: Available for commercial users
- Training: Custom training and onboarding
- Consulting: Architecture and implementation guidance
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT License (LICENSE-MIT)
at your option.
Acknowledgments
OpenCrates is built with and inspired by amazing open-source projects:
- Rust Language: For safety and performance
- OpenAI: For cutting-edge AI capabilities
- Tokio: For async runtime excellence
- Axum: For modern web framework design
- Ratatui: For beautiful terminal interfaces
Made with ❤️ by the OpenCrates Team
Empowering Rust developers with AI-driven tools for the future of software development.