8000 GitHub - Thewsthews/Restful: A simple API for a bookstore service
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Thewsthews/Restful

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

BookStore API πŸ‘Ύ

License Ruby Version Rust Version

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.

Architecture 🍯

/bookstore-api
β”œβ”€β”€ rails-service/    # Rails API service
└── rust-service/     # Rust computational service

Features πŸŒ™

  • πŸ” JWT Authentication
  • πŸ“š Book Management
  • πŸ” Advanced Search Algorithm
  • πŸ’« Real-time Recommendations
  • πŸ“Š Rating System
  • 🏷️ Category Management
  • πŸ”„ Order Processing

Prerequisites βš™οΈ

  • Ruby 3.2.2
  • Rust 1.75.0
  • SQLite3
  • Bundler
  • Cargo

Installation πŸ›οΈ

  1. Clone the repository
git clone https://github.com/yourusername/bookstore-api.git
cd bookstore-api
  1. Set up Rails service
cd rails-service
bundle install
rails db:create
rails db:migrate
rails db:seed
  1. Set up Rust service
cd ../rust-service
cargo build

Configuration πŸ”‘

  1. Environment Variables
# .env
RAILS_ENV=development
RUST_SERVICE_URL=http://localhost:7878
JWT_SECRET=your_jwt_secret
  1. Database Configuration
# config/database.yml
default: &default
  adapter: sqlite3
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  timeout: 5000

Running the Services 🧲

  1. Start Rails server
cd rails-service
rails server -p 3000
  1. Start Rust server
cd rust-service
cargo run

API Endpoints πŸ“

Authentication

POST   /api/v1/authenticate    # Login
POST   /api/v1/register       # Register new user

Books πŸ“š

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

Search & Recommendations πŸ”

POST   /api/v1/books/search           # Search books
GET    /api/v1/books/recommendations  # Get recommendations

API Usage Examples

Authentication πŸ”—

const response = await fetch('api/v1/authenticate', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    email: 'user@example.com',
    password: 'password123'
  })
});

Create Book

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
    }
  })
});

Testing 🍴

Rails Tests

cd rails-service
rails test

Rust Tests

cd rust-service
cargo test

Performance βš“

  • Rails API: Handles ~1000 requests/second
  • Rust Service: Handles ~10,000 requests/second
  • Search Response Time: < 100ms
  • Recommendation Generation: < 200ms

Security πŸ›‘οΈ

  • JWT Authentication
  • CORS Protection
  • Request Rate Limiting
  • Input Validation
  • SQL Injection Prevention
  • XSS Protection

Contributing 🀝🏾

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License βš–οΈ

This project is licensed under the MIT License - see the LICENSE.md file for details

Contact ☎️

🐧 - @dvble.m Project Link: https://github.com/Thewsthews/Restful

Acknowledgments ✊🏾

  • Ruby on Rails Team
  • Rust Team
  • All contributors

About

A simple API for a bookstore service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0