A simple and elegant phonebook application built with Ruby and Sinatra framework. This project demonstrates core web development concepts including CRUD operations, XML data persistence, and modern UI design.
- Create, read, update, and delete contacts
- Alphabetical organization of contacts by first letter
- No database required - contacts stored as XML files
- Modern gradient-based UI with Bootstrap 4
- Responsive design with mobile support
- AJAX-powered modal dialogs for editing contacts
- Flash messages for user feedback
- Docker support for easy deployment
- Ruby 3.3 - Programming language
- Sinatra - Lightweight web framework
- Nokogiri - XML parsing and manipulation
- Bootstrap 4.1.3 - UI framework with Bootswatch theme
- jQuery 3.3.1 - DOM manipulation and AJAX
- Font Awesome 4.7.0 - Icon library
- Docker - Containerization
easy-phonebook-ruby/
├── app.rb # Main application file with routes
├── Gemfile # Ruby dependencies
├── Dockerfile # Docker container configuration
├── docker-compose.yml # Docker Compose orchestration
├── seed.rb # Sample data generator
├── models/
│ └── contact.rb # Contact model with XML operations
├── helpers/
│ └── contacts_helper.rb # View helper methods
├── views/
│ ├── layout.erb # Master layout template
│ ├── index.erb # Homepage with alphabet grid
│ ├── list.erb # Contact listing by letter
│ ├── new.erb # New contact form
│ └── show.erb # Edit contact form
├── public/
│ └── assets/
│ ├── css/ # Stylesheets
│ ├── js/ # JavaScript files
│ ├── fonts/ # Font files
│ └── font-awesome/ # Font Awesome assets
└── contacts/
└── letters/ # XML files organized by letter
-
Make sure Docker and Docker Compose are installed on your system
-
Clone the repository:
git clone <repository-url>
cd easy-phonebook-ruby- Build and run with Docker Compose:
docker-compose up --build-
Access the application at
http://localhost:4567 -
To stop the application:
docker-compose down-
Make sure Ruby 3.3+ is installed on your system
-
Clone the repository:
git clone <repository-url>
cd easy-phonebook-ruby- Install dependencies:
bundle install- Run the application:
ruby app.rb- Access the application at
http://localhost:4567
- Click on "New Contact" in the navigation bar
- Fill in the contact details (name, email, birthdate, phone number)
- Click "Save Contact"
- The contact will be saved and organized alphabetically
- On the homepage, click on any letter (A-Z) to view contacts
- Alternatively, use the "Contacts" dropdown in the navigation bar
- Click "View / Edit" to see contact details
- Navigate to a contact and click "View / Edit"
- Modify the contact information in the modal dialog
- Click "Save Changes"
- The original contact will be updated
- Navigate to a contact
- Click "Delete"
- Confirm the deletion
- The contact will be permanently removed
Contacts are stored as XML files in the contacts/letters/ directory, organized by the first letter of the contact's name. Each contact is saved in a separate XML file with the following structure:
<?xml version="1.0" encoding="UTF-8"?>
<contact>
<name>John Doe</name>
<email>john@example.com</email>
<birthdate>1990-01-15</birthdate>
<phone_number>+1234567890</phone_number>
</contact>When using Docker, contact data is persisted in a named volume (phonebook-data) to ensure data survives container restarts.
This project was created for educational purposes to demonstrate:
- Ruby web development with Sinatra
- XML data manipulation with Nokogiri
- RESTful routing patterns
- Server-side rendering with ERB templates
- AJAX requests for dynamic content
- CSS custom properties and modern design
- Docker containerization
This project is provided as-is for educational purposes.
Feel free to fork this project and submit pull requests with improvements.