2 unstable releases
| 0.2.0 | Aug 19, 2025 |
|---|---|
| 0.1.0 | Aug 16, 2025 |
#343 in #openapi
31 downloads per month
Used in 2 crates
(via elif-openapi)
9KB
133 lines
elif.rs
LLM-friendly Rust web framework designed for AI agent-driven development
elif.rs is a spec-first, AI-agent-optimized web framework designed to enable AI agents (like Claude) to build complex web applications through safe, structured code generation with MARKER-based editing zones.
๐ง Current Status: Phase 1 Complete (Architecture Foundation)
elif.rs is in active development. Phase 1 (Architecture Foundation) is now complete with all core systems implemented and tested.
โ Completed (Phase 1: Architecture Foundation)
- Dependency Injection System: Complete DI container using
service-buildercrate - Service Provider System: Lifecycle management, dependency resolution, boot ordering
- Module System: Feature organization with dependency resolution and topological sorting
- Configuration Management: Environment-based config with validation, hot-reload support
- Application Lifecycle: Startup/shutdown management, signal handling, lifecycle hooks
๐ง In Development (Phase 2: Database Layer)
- Full ORM with relationships and query builder
- Connection pooling and transaction management
- Model events and observers
- Database seeding and factory system
๐ Planned (Phase 3-6)
- Authentication & Authorization (JWT, sessions, RBAC)
- Security middleware (CORS, CSRF, rate limiting)
- Developer experience tools (hot reload, introspection APIs)
- Production features (monitoring, clustering, deployment)
- Advanced features (real-time, job queues, caching)
๐ฏ Why elif.rs?
Traditional web frameworks are designed for human developers. elif.rs is specifically designed for AI agents:
- ๐ค AI-Safe Architecture: Robust dependency injection and lifecycle management
- ๐ Spec-First Development: Configuration-driven architecture
- โก Modular Design: Plugin system for extensible functionality
- ๐ง LLM-Optimized: Clear separation of concerns and predictable patterns
- ๐ Introspective: Built-in project understanding capabilities (planned)
๐ Quick Start
1. Prerequisites
- Rust 1.70+
- Git
2. Clone and Build
git clone https://github.com/krcpa/elif.rs
cd elif.rs
cargo build --release
3. Run Tests
cargo test --workspace
4. Explore the Architecture
# Check core functionality
cargo test -p elif-core
# View project structure
find crates -name "*.rs" | head -20
๐๏ธ Architecture Overview
elif.rs follows a modular, dependency-injection-based architecture:
elif.rs/
โโโ crates/
โ โโโ core/ # ๐ข Architecture foundation (Phase 1)
โ โ โโโ container/ # Dependency injection container
โ โ โโโ provider/ # Service provider system
โ โ โโโ module/ # Module system & app lifecycle
โ โ โโโ config/ # Configuration management
โ โ
โ โโโ orm/ # ๐ก Database layer (Phase 2)
โ โโโ auth/ # ๐ด Authentication (Phase 3)
โ โโโ security/ # ๐ด Security middleware (Phase 3)
โ โโโ cli/ # ๐ก Command line interface
โ โโโ codegen/ # ๐ด Code generation (Phase 4+)
โ
โโโ apps/
โ โโโ api/ # Example API application
โ
โโโ plan/ # Development roadmap & specifications
โโโ phase1/ # โ
Architecture (COMPLETE)
โโโ phase2/ # ๐ก Database layer (IN PROGRESS)
โโโ phase3-6/ # ๐ด Future phases
Legend: ๐ข Complete | ๐ก In Progress | ๐ด Planned
๐ค AI Agent Development Model
elif.rs is designed for the "Plan โ Implement โ Test โ Deploy" AI workflow:
1. Plan: Architecture-First Design
// Phase 1: Define application structure
use elif_core::{Application, Module, ServiceProvider};
let app = Application::builder()
.provider(DatabaseProvider)
.provider(AuthProvider)
.module(ApiModule)
.module(WebModule)
.build()?;
2. Implement: Module-Based Development
// Phase 2: Implement feature modules
pub struct BlogModule;
impl Module for BlogModule {
fn name(&self) -> &'static str { "blog" }
fn configure(&self, builder: ContainerBuilder) -> Result<ContainerBuilder, ModuleError> {
// Configure services for this module
Ok(builder.service(BlogService::new()))
}
fn routes(&self) -> Vec<RouteDefinition> {
vec![
RouteDefinition::new(HttpMethod::GET, "/posts", "list_posts"),
RouteDefinition::new(HttpMethod::POST, "/posts", "create_post"),
]
}
}
3. Test: Comprehensive Testing
# All tests pass with full coverage
cargo test --workspace # โ
35+ tests passing
4. Deploy: Production-Ready
// Phase 1: Application lifecycle management
app.start().await?; // Graceful startup
// ... handle requests ...
app.shutdown().await?; // Graceful shutdown
๐งช Testing & Development
Running Tests
# Core architecture tests
cargo test -p elif-core # โ
33/33 tests passing
# All workspace tests
cargo test --workspace # โ
All tests passing
# Specific test suites
cargo test -p elif-core -- module::tests # Module system tests
cargo test -p elif-core -- provider::tests # Provider system tests
Code Quality
# Check code formatting
cargo fmt --check
# Run clippy linting
cargo clippy -- -D warnings
# Build with optimizations
cargo build --release
๐ง Current Implementation Details
Dependency Injection (Phase 1.1 โ )
use elif_core::{Container, ContainerBuilder};
// Service registration with automatic dependency resolution
let container = Container::builder()
.config(app_config)
.database(database_connection)
.build()?;
let config = container.config();
let db = container.database();
Service Providers (Phase 1.2 โ )
use elif_core::{ServiceProvider, ProviderRegistry};
pub struct DatabaseProvider;
impl ServiceProvider for DatabaseProvider {
fn name(&self) -> &'static str { "database" }
fn register(&self, builder: ContainerBuilder) -> Result<ContainerBuilder, ProviderError> {
let db = create_database_connection()?;
Ok(builder.database(Arc::new(db)))
}
fn dependencies(&self) -> Vec<&'static str> {
vec!["config"] // Depends on config provider
}
}
Module System (Phase 1.3 โ )
use elif_core::{Module, ModuleRegistry, RouteDefinition, HttpMethod};
pub struct ApiModule;
impl Module for ApiModule {
fn name(&self) -> &'static str { "api" }
fn routes(&self) -> Vec<RouteDefinition> {
vec![
RouteDefinition::new(HttpMethod::GET, "/health", "health_check")
.with_description("Health check endpoint"),
]
}
fn dependencies(&self) -> Vec<&'static str> {
vec!["auth"] // Requires auth module
}
}
Configuration Management (Phase 1.4 โ )
use elif_core::{AppConfig, Environment, AppConfigTrait};
// Environment-based configuration with validation
let config = AppConfig::from_env()?;
assert_eq!(config.environment, Environment::Development);
assert_eq!(config.server.port, 3000);
// Configuration validation
config.validate()?; // Ensures all required fields are present
Application Lifecycle (Phase 1.5 โ )
use elif_core::{Application, ApplicationState, LifecycleHook};
// Custom lifecycle hooks
pub struct DatabaseMigrationHook;
impl LifecycleHook for DatabaseMigrationHook {
fn name(&self) -> &'static str { "database_migration" }
fn before_start<'life0, 'async_trait>(
&'life0 self,
container: &'life0 Container,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>> {
Box::pin(async move {
// Run database migrations before app starts
run_migrations(container.database()).await?;
Ok(())
})
}
}
// Application with lifecycle management
let mut app = Application::builder()
.provider(DatabaseProvider)
.module(ApiModule)
.lifecycle_hook(DatabaseMigrationHook)
.build()?;
// Graceful startup and shutdown
app.start().await?;
assert_eq!(app.state(), &ApplicationState::Running);
app.shutdown().await?;
assert_eq!(app.state(), &ApplicationState::Stopped);
๐ Development Roadmap
Phase 1: Architecture Foundation โ (Complete)
- Dependency injection system
- Service provider lifecycle management
- Module system with dependency resolution
- Configuration management with validation
- Application lifecycle and bootstrapping
- Status: All 33 core tests passing, production-ready architecture
Phase 2: Database Layer ๐ง (Next)
- Full ORM with relationships and query builder
- Connection pooling and transaction management
- Model events and observers
- Database seeding and factory system
Phase 3: Security Core ๐ด (Planned)
- Authentication system (JWT, session)
- Authorization with roles and permissions
- Input validation and sanitization
- Security middleware (CORS, CSRF, rate limiting)
Phase 4-6: Developer Experience & Production Features ๐ด (Future)
- Hot reload and development tools
- Introspection APIs and project understanding
- Production monitoring and clustering
- Advanced features (real-time, jobs, caching)
Track Progress: GitHub Project Board
๐ค Contributing
elif.rs is built for the AI development community. Contributions welcome!
Development Setup
git clone https://github.com/krcpa/elif.rs
cd elif.rs
cargo build --release
cargo test --workspace # Ensure all tests pass
Contribution Guidelines
- Phase-based development: Focus on current phase (Phase 2: Database Layer)
- Test-driven: All features must have comprehensive tests
- AI-friendly: Code should be easily understood by LLMs
- Documentation: Clear examples and inline documentation
Current Priorities (Phase 2)
- ORM implementation with relationships
- Database connection pooling
- Transaction management
- Model event system
๐ Project Stats
- Architecture: โ Production-ready foundation
- Tests: โ 33+ tests, all passing
- Build: โ Clean compilation, minimal warnings
- Documentation: โ Comprehensive inline docs
- AI Compatibility: โ LLM-optimized code structure
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Links
- Repository: https://github.com/krcpa/elif.rs
- Issues: GitHub Issues
- Project Board: Development Roadmap
- Discussions: GitHub Discussions
Built for the future of AI-driven development ๐ค
Phase 1 Complete: Architecture Foundation Ready
Next: Phase 2 Database Layer Development
Dependencies
~0.6โ1.4MB
~30K SLoC