| Crates.io | opencrates |
| lib.rs | opencrates |
| version | 3.0.1 |
| created_at | 2025-06-04 01:45:50.8665+00 |
| updated_at | 2025-06-09 03:08:47.157673+00 |
| description | Enterprise-grade AI-powered Rust development companion with comprehensive automation, monitoring, and deployment capabilities |
| homepage | https://opencrates.dev |
| repository | https://github.com/opencrates/opencrates |
| max_upload_size | |
| id | 1699733 |
| size | 1,437,402 |
An intelligent Rust crate generator and registry management system powered by AI
# Install from crates.io
cargo install opencrates
# Or add as dependency
cargo add opencrates
# Pull and run
docker pull opencrates/opencrates:latest
docker run -p 8080:8080 opencrates/opencrates
# Or build locally
docker build -t opencrates .
docker-compose up
use opencrates::{OpenCrates, providers::OpenAIProvider};
use anyhow::Result;
#[tokio::main]
async fn main() -> Result<()> {
// Initialize OpenCrates
let opencrates = OpenCrates::new().await?;
// Generate a new crate
opencrates.generate_crate(
"my-awesome-crate",
"A fantastic Rust library",
vec!["async".to_string(), "serde".to_string()],
"./output".into()
).await?;
// Analyze existing project
let analysis = opencrates.analyze_crate("./my-project").await?;
println!("Project analysis: {:#?}", analysis);
Ok(())
}
# Generate a new crate
opencrates generate --name "my-crate" --description "A sample crate" --output ./output
# Analyze existing crate
opencrates analyze ./existing-project
# Start the server
opencrates server --host 0.0.0.0 --port 8080
# Health check
opencrates health
# Interactive mode
opencrates interactive
OpenCrates supports comprehensive configuration through multiple sources:
export OPENCRATES_ENV=production
export OPENAI_API_KEY=your_api_key_here
export OPENCRATES_DATABASE_URL=sqlite:./opencrates.db
export OPENCRATES_REDIS_URL=redis://localhost:6379
export OPENCRATES_LOG_LEVEL=info
opencrates.toml)[server]
host = "127.0.0.1"
port = 8080
workers = 4
[database]
url = "sqlite:./opencrates.db"
max_connections = 10
[ai]
provider = "openai"
model = "gpt-4"
temperature = 0.7
max_tokens = 4000
[cache]
backend = "redis"
ttl = 3600
max_size = 1000
[monitoring]
enabled = true
health_check_interval = 30
enable_profiling = false
[security]
enable_auth = true
enable_rate_limiting = true
jwt_secret = "your-secret-key"
[features]
enable_web_ui = true
enable_api = true
enable_cli = true
use opencrates::utils::config::OpenCratesConfig;
let config = OpenCratesConfig {
server: ServerConfig {
host: "0.0.0.0".to_string(),
port: 3000,
workers: 8,
..Default::default()
},
ai: AiConfig {
provider: "openai".to_string(),
model: "gpt-4-turbo".to_string(),
temperature: 0.8,
..Default::default()
},
..Default::default()
};
let opencrates = OpenCrates::new_with_config(config).await?;
# Install Rust (latest stable)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install required tools
cargo install cargo-audit cargo-tarpaulin
# For full development
docker-compose up -d redis postgres
# Clone the repository
git clone https://github.com/your-username/opencrates.git
cd opencrates
# Build in development mode
cargo build
# Build optimized release
cargo build --release
# Run with all features
cargo run --all-features -- --help
# Run all tests
cargo test --all-features
# Run specific test suites
cargo test --test basic_functionality
cargo test --test integration_tests
cargo test --test codex_integration
# Run with coverage
cargo tarpaulin --all-features --out html
# Benchmark tests
cargo bench
# Security audit
cargo audit
# Comprehensive build and test
./build_and_test.sh
# Quick test run
./test_all.sh
# Format and lint
cargo fmt
cargo clippy --all-features -- -D warnings
# Generate documentation
cargo doc --no-deps --all-features --open
OpenCrates/
├── Core Engine # Central orchestration
│ ├── Template Manager # Code generation templates
│ ├── Provider Registry # AI provider management
│ └── Configuration # System configuration
├── Providers/ # AI service integrations
│ ├── OpenAI # GPT-4, GPT-3.5-turbo
│ ├── Codex # GitHub Copilot integration
│ └── Custom # Extensible provider system
├── Server/ # FastAPI-style HTTP server
│ ├── REST API # RESTful endpoints
│ ├── WebSocket # Real-time communication
│ └── GraphQL # Advanced querying
├── CLI/ # Command-line interface
│ ├── Interactive # REPL-style interaction
│ ├── Batch # Script automation
│ └── TUI # Terminal user interface
├── Storage/ # Data persistence
│ ├── SQLite # Embedded database
│ ├── PostgreSQL # Production database
│ └── Redis # Caching and sessions
└── Monitoring/ # Observability stack
├── Metrics # Prometheus integration
├── Logging # Structured logging
└── Tracing # Distributed tracing
[Client Request]
↓
[Rate Limiting & Auth]
↓
[Request Validation]
↓
[Provider Selection]
↓
[AI Processing]
↓
[Template Application]
↓
[Code Generation]
↓
[Quality Validation]
↓
[Response Formation]
↓
[Client Response]
// Core entities
pub struct CrateSpec {
pub name: String,
pub description: String,
pub version: String,
pub dependencies: HashMap<String, String>,
pub features: Vec<String>,
pub metadata: CrateMetadata,
}
pub struct GenerationRequest {
pub prompt: String,
pub context: String,
pub provider: String,
pub model: String,
pub parameters: GenerationParameters,
}
pub struct AnalysisResult {
pub metrics: CodeMetrics,
pub dependencies: DependencyGraph,
pub suggestions: Vec<Improvement>,
pub security: SecurityReport,
}
# Prometheus metrics endpoint
curl http://localhost:8080/metrics
# Health check endpoint
curl http://localhost:8080/health
# System status
curl http://localhost:8080/status
use tracing::{info, warn, error};
// Structured logging with context
info!(
user_id = %user.id,
crate_name = %spec.name,
generation_time_ms = generation_time.as_millis(),
"Crate generation completed successfully"
);
// JWT-based authentication
#[derive(Serialize, Deserialize)]
struct Claims {
sub: String,
role: UserRole,
exp: usize,
}
// Role-based access control
#[derive(Serialize, Deserialize)]
enum UserRole {
Admin,
Developer,
ReadOnly,
}
# Crate generation
POST /api/v1/generate
Content-Type: application/json
{
"name": "my-crate",
"description": "Description here",
"features": ["async", "serde"],
"template": "library"
}
# Project analysis
POST /api/v1/analyze
Content-Type: multipart/form-data
# Health check
GET /health
# Metrics
GET /metrics
# OpenAPI specification
GET /docs
// Real-time generation updates
const ws = new WebSocket('ws://localhost:8080/ws/generate');
ws.onmessage = (event) => {
const update = JSON.parse(event.data);
console.log('Generation progress:', update.progress);
};
We welcome contributions! Please see our Contributing Guide for details.
cargo fmt)cargo clippy)Licensed under either of:
at your option.
Major Release - Complete Rewrite
OpenCrates - Intelligent Rust Development, Powered by AI