A high-performance bookstore API built with Ruby on Rails and Rust. Rails handles the web interface and database operations, while Rust manages complex computations and search functionality.
/bookstore-api
βββ rails-service/ # Rails API service
βββ rust-service/ # Rust computational service
- π JWT Authentication
- π Book Management
- π Advanced Search Algorithm
- π« Real-time Recommendations
- π Rating System
- π·οΈ Category Management
- π Order Processing
- Ruby 3.2.2
- Rust 1.75.0
- SQLite3
- Bundler
- Cargo
- Clone the repository
git clone https://github.com/yourusername/bookstore-api.git
cd bookstore-api
- Set up Rails service
cd rails-service
bundle install
rails db:create
rails db:migrate
rails db:seed
- Set up Rust service
cd ../rust-service
cargo build
- Environment Variables
# .env
RAILS_ENV=development
RUST_SERVICE_URL=http://localhost:7878
JWT_SECRET=your_jwt_secret
- Database Configuration
# config/database.yml
default: &default
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
- Start Rails server
cd rails-service
rails server -p 3000
- Start Rust server
cd rust-service
cargo run
POST /api/v1/authenticate # Login
POST /api/v1/register # Register new user
GET /api/v1/books # List all books
POST /api/v1/books # Create a book
GET /api/v1/books/:id # Get a specific book
PUT /api/v1/books/:id # Update a book
DELETE /api/v1/books/:id # Delete a book
POST /api/v1/books/search # Search books
GET /api/v1/books/recommendations # Get recommendations
const response = await fetch('api/v1/authenticate', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: 'user@example.com',
password: 'password123'
})
});
const response = await fetch('api/v1/books', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
book: {
title: 'The Rust Programming Language',
author: 'Steve Klabnik',
genre: 'Technical',
price: 29.99
}
})
});
cd rails-service
rails test
cd rust-service
cargo test
- Rails API: Handles ~1000 requests/second
- Rust Service: Handles ~10,000 requests/second
- Search Response Time: < 100ms
- Recommendation Generation: < 200ms
- JWT Authentication
- CORS Protection
- Request Rate Limiting
- Input Validation
- SQL Injection Prevention
- XSS Protection
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE.md file for details
π§ - @dvble.m Project Link: https://github.com/Thewsthews/Restful
- Ruby on Rails Team
- Rust Team
- All contributors