An app for product management
Products App is a full-stack application that demonstrates how an independent React frontend can communicate with a Ruby on Rails backend through RESTful JSON API.
The project focus on full-stack integration between a Rails API backend and a modern JavaScript frontend, including API design, database persistence, CORS configuration, and client-side application development.
- 📦 Product creation, listing, updating, and deletion
- 🔌 RESTful JSON API
- 🔢 Versioned API under /api/v1
- ⚛️ Decoupled React frontend
- 🔄 React ↔ Rails API integration
- 🗄️ PostgreSQL persistence
- 🌐 CORS configuration
- 🧭 Client-side routing with React Router
- ⚡ Vite development environment
- 🌱 Development data generation with Faker
- 🐳 Docker support
- Ruby
- Ruby on Rails
- Rails API mode
- Active Record
- React 18
- JavaScript
- Vite
- Axios
- React Router
- PostgreSQL
- rack-cors
- Faker
- Puma
- Docker
ProductsApp uses a decoupled frontend/backend architecture.
The React application is responsible for the user interface and communicates with the Rails application through HTTP requests.
┌─────────────────────┐
│ │
│ React Frontend |
| |
| React + Vite |
| Axios |
| React Router │
│ |
| localhost:3000 │
│ │
└──────────┬──────────┘
│
│ HTTP / JSON
│
▼
┌─────────────────────┐
│ │
│ Rails API │
│ |
| /api/v1 |
| Controllers |
| |
| localhost:3001 │
│ │
└──────────┬──────────┘
│
│ Active Record
│
▼
┌─────────────────────┐
│ │
│ PostgreSQL │
│ │
└─────────────────────┘
This separation allows the frontend and backend to evolve independently while communicating through a clearly defined API boundary.
The Rails backend exposes product resources through RESTful endpoints under:
/api/v1/products
API versioning provides a clear boundary for future changes without coupling the frontend directly to an unversioned API.
Frontend / Backend Integration
The React frontend consumes the Rails API through HTTP requests using Axios
React component
↓
Axios requestability to work
↓
Rails API
↓
Active Record
↓
PostgreSQL
↓
JSON response
↓
React UI
CORS
Because the frontend and backend run as independent applications during development, the Rails API is configured with rack-cors to allow cross-origin communication.
Products are persisted in PostgreSQL through Rails Active Record, with database changes managed through Rails migrations.
The main product endpoints follow standard REST conventions:
Method Endpoint Purpose
GET /api/v1/products List products
GET /api/v1/products/:id Retrieve a product
POST /api/v1/products Create a product
PATCH /api/v1/products/:id Update a product
PUT /api/v1/products/:id Update a product
DELETE /api/v1/products/:id Delete a product
Example request:
POST /api/v1/products
Content-Type: application/json
{
"product": {
"name": "Wireless Headphones",
"price": 199.90,
"stock_quantity": 25,
"description": "Bluetooth wireless headphones"
}
}The API returns JSON responses and uses HTTP status codes to communicate successful operations and validation failures.
Automated testing is an important next step for the project.
The backend can be extended with RSpec request/model tests, while the React application can use a dedicated JavaScript testing framework for component and integration tests.
Example backend test command:
bundle exec rspec
Make sure you have installed:
- Ruby 3.1.2
- Rails 7.1.5
- PostgreSQL
- Node.js
- npm
- Bundler
Or run with Docker in a containerized environment.
git clone https://github.com/digidweb/products-app.git
cd products-appInstall Ruby dependencies:
bundle installCreate and configure the database:
rails db:create
rails db:migrate
rails db:seedStart the Rails API:
rails server -p 3001The Rails API will be available at:
http://localhost:3001
Open another terminal and navigate to the client:
cd clientInstall JavaScript dependencies:
npm installStart the React development server:
npm run devability to workVite will display the frontend development URL in the terminal.
The React application will communicate with the Rails API running on port 3001.
The project also includes Docker support.
docker build -t productsapp .docker run -p 3001:3001 productsappThe local development workflow above is recommended when working on both the Rails API and React frontend independently.
The project uses Faker to generate sample product data.
To recreate the seed data:
rails db:seedIf continuing the project, the following improvements would be natural next steps:
- Add automated request and model tests with RSpec
- Add React component and integration tests
- Add standardized API error responses
- Add authentication and authorization
- Add product search and filtering
- Add API documentation with OpenAPI/Swagger
- Add GitHub Actions for CI
- Add production deployment
ProductsApp is part of a portfolio focused on Ruby on Rails backend and full-stack development.
The project complements Rails-focused applications by demonstrating practical experience with:
Ruby on Rails · REST APIs · PostgreSQL · React · JavaScript · Axios · Vite · Docker
The project demonstrates ability to work with a different architecture from a traditional Rails application: instead of rendering the frontend through Rails views, the Rails application exposes a JSON API consumed by an independent React client.