A professional Ruby on Rails API for managing an e-commerce system with authentication, cart management, orders, reviews, and API documentation via Swagger.
- Features
- Tech Stack
- Prerequisites
- Installation
- Configuration
- Database Setup
- Running the Application
- API Documentation
- Authentication
- Error Handling
- Screenshots
- Deployment
- Contributing
- License
- Support
- 🔐 JWT authentication
- 👤 User registration & login
- 👨💼 role-based access control (admin/user)
- 📧 confirmation email via SendGrid
- 😧 forgot and reset password functionality
- 📦 Product & category management
- ❤️ Favorites system
- 🛍️ Cart & item operations with color/size selection
- 🧾 Orders & checkout
- 💬 Reviews
- 📘 Swagger-powered API docs
- 📄 Pagination with metadata
- Ruby 3.2+
- Rails 7+
- PostgreSQL
- RSwag (Swagger Docs)
- custom JWT auth
- RSpec, RuboCop, Brakeman
- sendgrid for email notifications
- Ruby (3.2+)
- PostgreSQL
- Node.js & Yarn
miseversion manager (recommended)
git clone https://github.com/Zeyad-Hassan-1/e-commerce-api.git
cd e-commerce-api
bundle install- Create
.envfile from the example:
cp .env.example .env- Fill in required environment variables:
SENDGRID_USERNAME=apikey
SENDGRID_PASSWORD=your_sendgrid_api_key
DATABASE_URL=your_database_url
JWT_SECRET=your_secret_key # to create secret key, run `rails secret`
RAILS_MASTER_KEY=your_master_key #found in config/master.keyrails db:create
rails db:migrate
rails db:seed # optionalrails serverVisit: http://localhost:3000
Available at: http://localhost:3000/api-docs
Uses JWT Bearer Token system.
- Register or login to get a token
- Include it in requests:
Authorization: Bearer your_token_hereStandard HTTP status codes:
2xx→ Success4xx→ Client error (e.g., Unauthorized, Not Found)5xx→ Server error
All error responses contain descriptive JSON messages.
Use any cloud provider or self-hosted solution
Or push to platforms like:
- Render
- Railway
- Fly.io
- Heroku (with container support)
Make sure:
DATABASE_URLis setRAILS_MASTER_KEYis passed as ENV variable
- Fork the repo
- Create a new branch:
git checkout -b feature/your-feature - Commit your changes:
git commit -m "Add some feature" - Push:
git push origin feature/your-feature - Submit a Pull Request
Created with ❤️ by Zeyad Hassan
For questions or help, open an issue on GitHub.