An open API service indexing awesome lists of open source software.

https://github.com/alanalvarez21/ecommerce-boilerplate

Ruby on Rails Ecommerce template
https://github.com/alanalvarez21/ecommerce-boilerplate

ruby ruby-app ruby-application ruby-apps ruby-gem ruby-gems ruby-lib ruby-on-rails rubygem rubyonrails

Last synced: 14 days ago
JSON representation

Ruby on Rails Ecommerce template

Awesome Lists containing this project

README

          

# ๐Ÿ›’ E-commerce Boilerplate - Rails Template

> **A complete e-commerce template built with Rails 8 to launch your online store in minutes**

[![Rails](https://img.shields.io/badge/Rails-8.0.1-red.svg)](https://rubyonrails.org/)
[![Ruby](https://img.shields.io/badge/Ruby-3.3.4-red.svg)](https://www.ruby-lang.org/)
[![Docker](https://img.shields.io/badge/Docker-Ready-blue.svg)](https://www.docker.com/)
[![CI](https://github.com/AlanAlvarez21/ecommerce-boilerplate/actions/workflows/ci.yml/badge.svg)](https://github.com/AlanAlvarez21/ecommerce-boilerplate/actions)

## ๐ŸŽฏ What is this project?

This is a complete e-commerce **boilerplate/template** designed to help you **launch your online store quickly**. It includes all the essential features you need to start selling products online, from inventory management to payment processing.

### โšก **Why use this boilerplate?**

- ๐Ÿš€ **5-minute setup** - Uses Docker and devcontainers for development without complex configurations
- ๐Ÿ’ณ **Ready payments** - Complete integration with MercadoPago
- ๐Ÿ“ฑ **Responsive** - Modern design with Tailwind CSS
- ๐Ÿ” **Admin panel** - Complete administration panel
- ๐Ÿ“Š **Analytics** - Dashboard with sales metrics and reports
- ๐ŸŒ **Multi-language** - Support for Spanish and English
- โœ… **Tested** - Complete test suite with RSpec

---

## ๐Ÿ›๏ธ Main Features

### **For Customers (Frontend)**
- ๐Ÿช **Product catalog** with categories and filters
- ๐Ÿ›’ **Shopping cart** with session management
- ๐Ÿ’ณ **Integrated checkout** with MercadoPago
- ๐Ÿ“ฑ **Responsive design** optimized for mobile
- ๐Ÿ” **Intuitive search and navigation**

### **For Administrators (Backend)**
- ๐Ÿ“Š **Dashboard with metrics** for sales and analytics
- ๐Ÿ“ฆ **Product management** (full CRUD)
- ๐Ÿ“‚ **Category management** with images
- ๐Ÿ“‹ **Order management** and status tracking
- ๐Ÿ“ˆ **Inventory control** and stock management
- ๐Ÿ‘ฅ **Admin user system** with Devise

### **Technical**
- ๐Ÿš€ **Rails 8.0.1** with latest improvements
- ๐Ÿ˜ **PostgreSQL** as database
- โšก **Stimulus + Turbo** for interactivity
- ๐ŸŽจ **Tailwind CSS** for styling
- ๐Ÿณ **Docker** with devcontainers
- ๐Ÿงช **RSpec** for testing
- ๐Ÿ”’ **Brakeman** for security
- ๐Ÿ“ˆ **GitHub Actions** CI/CD

---

## ๐Ÿš€ Quick Start

### **1. Prerequisites**
```bash
# Install Docker
https://www.docker.com/

# Install Devcontainers CLI
npm install -g @devcontainers/cli
# or with npx
npx install -g @devcontainers/cli
```

### **2. Clone and run**
```bash
# Clone the repository
git clone https://github.com/AlanAlvarez21/ecommerce-boilerplate.git
cd ecommerce-boilerplate

# Build the container (includes DB setup)
bin/build_container

# Seed the database with sample data
bin/rails db:seed

# Start the application
bin/dev
```

### **3. Ready! ๐ŸŽ‰**
- **Frontend**: http://localhost:3000
- **Admin Panel**: http://localhost:3000/admin
- **Admin Credentials**:
- Email: `admin@coinsapp.com`
- Password: `password123`

---

## ๐Ÿ“ Project Structure

```
โ”œโ”€โ”€ app/
โ”‚ โ”œโ”€โ”€ controllers/
โ”‚ โ”‚ โ”œโ”€โ”€ admin/ # Administration panel
โ”‚ โ”‚ โ”œโ”€โ”€ application_controller.rb
โ”‚ โ”‚ โ”œโ”€โ”€ cart_controller.rb
โ”‚ โ”‚ โ”œโ”€โ”€ checkout_controller.rb
โ”‚ โ”‚ โ””โ”€โ”€ ...
โ”‚ โ”œโ”€โ”€ models/
โ”‚ โ”‚ โ”œโ”€โ”€ admin.rb # Admin users (Devise)
โ”‚ โ”‚ โ”œโ”€โ”€ category.rb # Product categories
โ”‚ โ”‚ โ”œโ”€โ”€ product.rb # Products
โ”‚ โ”‚ โ”œโ”€โ”€ order.rb # Purchase orders
โ”‚ โ”‚ โ”œโ”€โ”€ stock.rb # Inventory control
โ”‚ โ”‚ โ””โ”€โ”€ ...
โ”‚ โ”œโ”€โ”€ views/
โ”‚ โ”‚ โ”œโ”€โ”€ admin/ # Admin panel views
โ”‚ โ”‚ โ”œโ”€โ”€ layouts/ # Layouts (app and admin)
โ”‚ โ”‚ โ””โ”€โ”€ ...
โ”‚ โ””โ”€โ”€ services/
โ”‚ โ””โ”€โ”€ mercado_pago_sdk.rb # Payment integration
โ”œโ”€โ”€ config/
โ”‚ โ”œโ”€โ”€ routes.rb # Application routes
โ”‚ โ””โ”€โ”€ ...
โ”œโ”€โ”€ db/
โ”‚ โ”œโ”€โ”€ migrate/ # Migrations
โ”‚ โ””โ”€โ”€ seeds.rb # Sample data
โ””โ”€โ”€ spec/ # Tests with RSpec
```

---

## ๐Ÿ’ณ Payment Setup (MercadoPago)

### **1. Get credentials**
1. Create account at [MercadoPago Developers](https://www.mercadopago.com/developers)
2. Get your `ACCESS_TOKEN` and `PUBLIC_KEY`

### **2. Configure environment variables**
```bash
# In .env or in your system
export MERCADOPAGO_ACCESS_TOKEN="your_access_token"
export MERCADOPAGO_PUBLIC_KEY="your_public_key"
```

### **3. Configure webhook**
```bash
# Webhook URL for notifications
https://your-domain.com/webhooks/mercadopago
```

---

## ๐Ÿ› ๏ธ Development Commands

```bash
# Development
bin/dev # Server + Tailwind watcher
bin/rails server # Rails server only
bin/rails tailwindcss:watch # Tailwind watcher only

# Database
bin/rails db:create # Create database
bin/rails db:migrate # Run migrations
bin/rails db:seed # Seed with sample data
bin/rails db:reset # Reset and seed

# Testing
bundle exec rspec # Run tests
bin/brakeman # Security analysis
bin/rubocop # Code linting

# Assets
bin/rails assets:precompile # Compile assets for production
bin/rails tailwindcss:build # Build Tailwind CSS
```

---

## ๐ŸŽจ Customization

### **1. Change visual theme**
```scss
// In app/assets/stylesheets/application.tailwind.css
// Customize main colors
:root {
--primary-color: #3b82f6;
--secondary-color: #64748b;
}
```

### **2. Modify default products**
```ruby
# In db/seeds.rb
# Change categories and products according to your business
categories = Category.create!([
{
name: "Your Category",
description: "Your category description",
# ...
}
])
```

### **3. Customize texts**
```yaml
# In config/locales/en.yml
en:
app_name: "Your Store"
meta_title: " - The best online store"
# ...
```

---

## ๐Ÿ“Š Administration Panel

The admin panel includes:

- **๐Ÿ“ˆ Dashboard**: Sales metrics, recent orders, best-selling products
- **๐Ÿ›๏ธ Products**: Full CRUD with image management
- **๐Ÿ“‚ Categories**: Organization with catalog images
- **๐Ÿ“‹ Orders**: Status management and tracking
- **๐Ÿ“ฆ Inventory**: Stock control per product
- **๐Ÿ‘ฅ Admins**: Administrator user management

### **Access**
- URL: `/admin`
- Authentication: Devise
- Permissions: Admin users only

---

## ๐Ÿงช Testing

Complete test suite:

```bash
# Unit tests
bundle exec rspec spec/models/

# Controller tests
bundle exec rspec spec/controllers/

# Request tests
bundle exec rspec spec/requests/

# System tests (E2E)
bundle exec rspec spec/system/

# Coverage report
open coverage/index.html
```

---

## ๐Ÿš€ Deployment

### **Heroku**
```bash
# Create application
heroku create your-store

# Configure variables
heroku config:set RAILS_MASTER_KEY=your_master_key
heroku config:set MERCADOPAGO_ACCESS_TOKEN=your_token

# Deploy
git push heroku main

# Initial setup
heroku run rails db:migrate
heroku run rails db:seed
```

๐ŸŽฏ Seeds summary:
๐Ÿ“‚ Categories: 6
๐Ÿช™ Products: 15
๐Ÿ“ฆ Stock entries: 15
๐Ÿ‘ค Admins: 1
๐Ÿ“‹ Orders: 5
๐Ÿ›’ Order products: 11

๐Ÿ” Admin credentials:
Email: admin@coinsapp.com
Password: password123

### **Docker Production**
```bash
# Build image
docker build -t your-store .

# Run
docker run -p 3000:3000 \
-e RAILS_ENV=production \
-e DATABASE_URL=postgres://... \
your-store
```

---

## ๐Ÿค Contributing

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

---

## ๐Ÿ“ Ideal Use Cases

This boilerplate is perfect for:

- ๐Ÿช **Small/medium stores** that need quick online presence
- ๐Ÿ’Ž **Specialized products** (jewelry, collectibles, crafts)
- ๐ŸŽจ **Artists and makers** who want to sell their creations
- ๐Ÿ“š **Educational or niche stores**
- ๐Ÿš€ **E-commerce MVPs** to validate business ideas
- ๐Ÿ‘จโ€๐Ÿ’ป **Developers** who need a solid starting point

---

## ๐Ÿ“‹ Roadmap

### **Upcoming features:**
- [ ] ๐Ÿ” Advanced search with filters
- [ ] โญ Review and rating system
- [ ] ๐Ÿ“ง Integrated email marketing
- [ ] ๐Ÿ“ฑ PWA (Progressive Web App)
- [ ] ๐ŸŒ More payment gateways
- [ ] ๐Ÿ“ฆ Shipping system integration
- [ ] ๐Ÿค– Basic chatbot
- [ ] ๐Ÿ“Š Advanced analytics

---

## ๐Ÿ“„ License

This project is under the MIT license. See `LICENSE` for more details.

---

## ๐Ÿ†˜ Support

- ๐Ÿ“– **Documentation**: [Project Wiki](https://github.com/AlanAlvarez21/ecommerce-boilerplate/wiki)
- ๐Ÿ› **Issues**: [Report problems](https://github.com/AlanAlvarez21/ecommerce-boilerplate/issues)
- ๐Ÿ’ฌ **Discussions**: [GitHub Discussions](https://github.com/AlanAlvarez21/ecommerce-boilerplate/discussions)

---

**๐Ÿš€ Launch your e-commerce today!** This boilerplate saves you weeks of initial development.