Rustelo/docs/examples/README.md

219 lines
4.7 KiB
Markdown
Raw Normal View History

2026-02-08 20:12:31 +00:00
# Rustelo Usage Examples
## Quick Start
### Creating a New Project with Features
```bash
# Create new project directory
mkdir my-rustelo-app && cd my-rustelo-app
# Copy foundation structure
cp -r /path/to/rustelo/foundation/* .
# Add desired features
cargo rustelo features add analytics
cargo rustelo features add smart-build
# Check status
cargo rustelo features status
```
### Available Feature Combinations
#### Minimal Setup
```bash
# Just the foundation - basic Leptos + Axum
# No additional features needed
```
#### Analytics-Enabled
```bash
cargo rustelo features add analytics
# Provides: navigation tracking, server monitoring, browser analytics
```
#### Performance-Optimized
```bash
cargo rustelo features add smart-build
cargo rustelo features add analytics
# Provides: fast builds + performance monitoring
```
#### Full-Stack Development
```bash
cargo rustelo features add analytics
cargo rustelo features add smart-build
cargo rustelo features add debugging-tools
cargo rustelo features add ui-components
# Provides: complete development environment
```
## Real-World Examples
### Blog with Analytics
```bash
# Setup
mkdir my-blog && cd my-blog
cp -r /path/to/rustelo/foundation/* .
# Add analytics for visitor tracking
cargo rustelo features add analytics
# Configure analytics
echo 'ANALYTICS_ENABLED=true' >> .env
echo 'ANALYTICS_LOG_PATH=logs/blog-analytics' >> .env
# Build and run
cargo leptos build
cargo leptos serve
```
### E-commerce with Performance Monitoring
```bash
# Setup high-performance e-commerce site
mkdir my-shop && cd my-shop
cp -r /path/to/rustelo/foundation/* .
# Add performance features
cargo rustelo features add smart-build
cargo rustelo features add analytics
# Configure for production
echo 'SMART_BUILD_PARALLEL_JOBS=8' >> .env
echo 'ANALYTICS_API_KEY=your-api-key' >> .env
# Fast development builds
cargo leptos watch # Uses smart-build caching
```
### Development Team Setup
```bash
# Full development environment
mkdir team-project && cd team-project
cp -r /path/to/rustelo/foundation/* .
# Add all development features
cargo rustelo features add analytics
cargo rustelo features add smart-build
cargo rustelo features add debugging-tools
# Team-specific configuration
echo 'SMART_BUILD_CACHE_DIR=.cache/team-build' >> .env
echo 'ANALYTICS_LOG_PATH=logs/team-analytics' >> .env
# Enhanced debugging available
# Use browser log analysis, server monitoring, etc.
```
## Feature-Specific Examples
### Analytics Feature
```bash
# Add analytics
cargo rustelo features add analytics
# Available commands:
# - Navigation tracking analysis
# - Server log monitoring
# - Browser error tracking
# - Performance reporting
# Example usage:
cargo run --bin analytics -- search --errors-only --hours 1
cargo run --bin analytics -- dashboard --refresh 30
cargo run --bin analytics -- report --type summary
```
### Smart Build Feature
```bash
# Add smart build
cargo rustelo features add smart-build
# Features:
# - Incremental builds with caching
# - Build performance optimization
# - Cache management tools
# Configuration:
echo 'SMART_BUILD_CACHE_DIR=.cache/builds' >> .env
echo 'SMART_BUILD_PARALLEL_JOBS=auto' >> .env
# Enhanced build performance automatically
cargo leptos build # Uses smart caching
```
## Custom Feature Development
### Creating a Custom Feature
```bash
# Create feature structure
mkdir -p features/my-custom-feature/templates
mkdir -p features/my-custom-feature/assets
mkdir -p features/my-custom-feature/scripts
# Create feature manifest
cat > features/my-custom-feature/feature.toml << 'EOF'
[feature]
name = "my-custom-feature"
version = "0.1.0"
description = "My custom functionality"
[dependencies]
workspace = ["serde", "tokio"]
external = []
[[environment.variables]]
name = "MY_FEATURE_ENABLED"
default = "true"
required = false
EOF
# Register in features registry
echo '[features.my-custom-feature]' >> registry/features.toml
echo 'description = "My custom functionality"' >> registry/features.toml
echo 'source = "local"' >> registry/features.toml
echo 'status = "available"' >> registry/features.toml
# Install custom feature
cargo rustelo features add my-custom-feature
```
## Troubleshooting
### Common Issues
```bash
# Feature not found
cargo rustelo features list # Check available features
# Dependency conflicts
cargo rustelo features status # Check for conflicts
# Integration issues
cargo rustelo features sync --force # Force resync
# Clean install
cargo rustelo features remove feature-name --clean-deps
cargo rustelo features add feature-name --force
```
### Getting Help
```bash
# CLI help
cargo rustelo --help
cargo rustelo features --help
# Feature documentation
cargo rustelo features explain analytics
# Status check
cargo rustelo features status
```