A command-line booking system built with Ruby and SQLite.
The application supports creating users, adding resources, making bookings with conflict checks, canceling bookings, and listing current records in table format.
- Overview
- Features
- Technology Stack
- System Architecture
- Project Structure
- Getting Started
- Usage
- Testing
- Known Issues
- Troubleshooting
- Data Model
- Implementation Notes
- Roadmap
This project provides a lightweight, file-based booking backend and a CLI interface:
app.rbhandles command parsing and console interaction.controllers/booking_manager.rbcoordinates application use-cases.models/*.rbencapsulate data access and booking rules.generator/id_generator.rbcentralizes ID generation for users, resources, and bookings.db/booking_system.dbstores persistent data in SQLite.
The design follows a simple layered pattern to keep responsibilities separate and implementation easy to extend.
- Interactive CLI commands for common booking operations
- User and resource registration with generated IDs
- Booking creation with overlap/conflict detection
- Booking cancellation with status tracking (
ACTIVE/CANCELLED) - Tabular listing for users, resources, and bookings
- Automated booking tests with
minitest - Explicit model dependency loading for
IDGeneratorinuser.rb,resource.rb, andbooking.rb
- Language: Ruby
- Database: SQLite3
- Testing: Minitest
- Console formatting: Terminal::Table (required by
controllers/booking_manager.rb)
CLI (app.rb)
|
v
Controller (BookingManager)
|
+--> User model ---------+
+--> Resource model -----+--> SQLite (db/booking_system.db)
+--> Booking model ------+
Shared utility: IDGenerator (used by User, Resource, Booking)
booking_system/
├── README.md # Project documentation
├── Gemfile # Gem dependencies
├── Gemfile.lock # Locked gem versions
├── app.rb # CLI entrypoint
├── controllers/
│ └── booking_manager.rb # Coordination layer
├── models/
│ ├── user.rb # User model and table setup
│ ├── resource.rb # Resource model and table setup
│ └── booking.rb # Booking model and conflict logic
├── generator/
│ └── id_generator.rb # ID generation utility
├── errors/
│ └── booking_system_error.rb # Custom application error
├── db/
│ └── booking_system.db # SQLite database file
├── test/
│ └── test_booking.rb # Booking behavior tests (minitest)
- Ruby 3.x recommended
- Bundler
- SQLite3 development headers installed on your OS
bundle installruby app.rb -helpSupported commands:
ruby app.rb -list users
ruby app.rb -list resources
ruby app.rb -list bookings
ruby app.rb -create user
ruby app.rb -add resource
ruby app.rb -make booking
ruby app.rb -cancel booking
ruby app.rb -help- Commands are case-sensitive and expected in lowercase.
- Dates should be entered in
yyyy-mm-ddformat. - Booking creation requires a valid user and resource.
- Booking conflicts are rejected based on booking date windows.
Run the booking test suite:
ruby test/test_booking.rbWhat is covered in test/test_booking.rb:
- successful booking creation
- conflict rejection for overlapping bookings
- successful non-conflicting second booking for the same resource
- booking existence lookup
- cancellation state transition to
CANCELLED - repeated cancellation behavior
- Booking creation currently allows only
assistantandstudentroles inapp.rb.
- If you get gem load errors, run
bundle installagain and usebundle exec ruby app.rb -help. - If local data state causes unexpected behavior during manual testing, remove
db/booking_system.dband rerun a command to recreate tables. - If tests fail due to stale local state, run
ruby test/test_booking.rbdirectly; the test suite resets tables in setup.
The application stores three primary entities:
- users:
id,name,role - resources:
id,name,category - bookings:
id,user_id,resource_id,start_date,end_date,status
Booking IDs, user IDs, and resource IDs are generated by IDGenerator.
IDGeneratoris now explicitly required where used:models/user.rbmodels/resource.rbmodels/booking.rb
- This removes reliance on file load order and prevents
NameErrorwhen models are loaded independently. - The test suite in
test/test_booking.rbresets tables per test for deterministic runs.
- Add a migration strategy for schema evolution
- Expand test coverage to include user/resource model behaviors
- Add input and business rule validations for date ordering
- Introduce CI workflow for automated test runs