This is a simple development environment for building a restaurant review application. It includes a Rails API backend, React frontend, and PostgreSQL database, all running in Docker containers.
The Docker containers are provided as a convenience so you do not need to install any dependencies. However, you can also run the applications directly on your machine if you prefer.
-
Start the application:
docker-compose up
-
Access the applications:
- Frontend (React): http://localhost:5173
- Backend (Rails API): http://localhost:3000
- Database (PostgreSQL): localhost:5432
That's it! All services will start automatically and the database will be created. Database migrations and seeding will run automatically on the first startup, so you'll have sample data ready to use immediately.
- Rails API (
foody_api/) - Ruby on Rails API server on port 3000 - React Frontend (
foody_ui/) - React + TypeScript + Vite on port 5173 - PostgreSQL Database - Running on port 5432
Credentials:
- Database:
foody_development - Username:
foody_user - Password:
password123 - Host:
localhost(orpostgresfrom within containers)
Rails console:
docker-compose exec foody_api rails consoleDatabase migrations:
docker-compose exec foody_api rails db:migrateSeed database:
docker-compose exec foody_api rails db:seedNote: Migrations and seeding happen automatically when the API container starts, so you typically don't need to run these commands manually.
Direct database access:
docker-compose exec postgres psql -U foody_user -d foody_developmentDefault test user:
- Email:
user@example.com - Password:
password
This user is automatically created when you run rails db:seed.
All source code is mounted into the containers, so any changes you make will be immediately reflected:
- Rails API changes are picked up automatically
- React changes trigger hot reload in the browser
When adding new dependencies in Docker, follow these steps to avoid architecture conflicts:
For Frontend (npm packages):
# 1. Add package to package.json or install locally
npm install package-name
# 2. Reinstall in Docker container to fix architecture conflicts
docker-compose run -T --rm foody_ui sh -c "rm -rf node_modules package-lock.json && npm install"
# 3. Restart the container
docker-compose restart foody_uiFor Backend (Ruby gems):
# Add gem using bundle add (recommended)
docker-compose exec foody_api bundle add gem-name
# Restart the container
docker-compose restart foody_apiAlternative (manual Gemfile editing):
# 1. Add gem to Gemfile manually
echo 'gem "gem-name"' >> foody_api/Gemfile
# 2. Rebuild container to install new gems
docker-compose build --no-cache foody_api
# 3. Restart the container
docker-compose restart foody_apiDocker containers may use different CPU architectures than your host machine. Installing packages locally then running in Docker can cause native binary conflicts, especially with build tools like Vite, Rollup, and native Ruby extensions.
For Ruby gems, bundle add is preferred because it properly updates both Gemfile and Gemfile.lock within the container while syncing changes to your host machine via volume mounting.
# Stop all services
docker-compose down
# Restart a specific service
docker-compose restart foody_api
# Run a one off command, such as resetting the database
docker-compose run --rm foody_api rails db:reset
# View logs
docker-compose logs foody_api
docker-compose logs foody_ui
# Rails console
docker-compose exec foody_api rails console
# Install dependencies (use methods above for new packages)
docker-compose exec foody_api bundle install
docker-compose exec foody_ui npm installfoody/
├── foody_api/ # Rails API backend
├── foody_ui/ # React frontend
├── docker-compose.yml # Docker orchestration
└── README.md # This file
Start building your application by modifying the code in foody_api/ and foody_ui/!