An interactive learning platform similar to RubyMonk, built with React and Node.js, where users can learn Ruby and Ruby on Rails through hands-on exercises and tutorials.
- Interactive Code Editor: Write and execute Ruby code directly in your browser using Monaco Editor (VS Code's editor)
- Comprehensive Lessons: Learn Ruby from basics to advanced topics, plus Ruby on Rails fundamentals
- Hands-on Exercises: Practice with real coding challenges and get instant feedback
- Progress Tracking: Track your learning progress with automatic saving to localStorage
- Beautiful UI: Modern, responsive dark theme inspired by GitHub
- Safe Code Execution: Backend API executes Ruby code securely with timeouts
- React 18 - UI framework
- Vite - Build tool and dev server
- Monaco Editor - Code editor (VS Code editor)
- Axios - HTTP client
- React Markdown - Markdown rendering
- Node.js - Runtime environment
- Express - Web framework
- Ruby 3.2+ - Code execution engine
rails_guide/
├── frontend/ # React frontend application
│ ├── src/
│ │ ├── components/ # React components
│ │ │ ├── CodeEditor.jsx # Monaco editor wrapper
│ │ │ ├── LessonViewer.jsx # Lesson content display
│ │ │ └── Sidebar.jsx # Navigation sidebar
│ │ ├── data/ # Lesson content
│ │ │ ├── rubyLessons.js # Ruby tutorials & exercises
│ │ │ └── railsLessons.js # Rails tutorials & exercises
│ │ ├── App.jsx # Main application component
│ │ ├── App.css # Application styles
│ │ └── main.jsx # Entry point
│ └── package.json
│
├── backend/ # Node.js backend API
│ ├── server.js # Express server & Ruby execution API
│ ├── Dockerfile # Docker configuration
│ └── package.json
│
└── README.md
- Node.js 20+ and npm
- Ruby 3.2+ installed and available in PATH
- Git for version control
-
Clone the repository
git clone <repository-url> cd rails_guide
-
Install backend dependencies
cd backend npm install -
Install frontend dependencies
cd ../frontend npm install -
Configure environment (optional)
cp .env.example .env # Edit .env if you want to change the API URL
You'll need two terminal windows/tabs:
Terminal 1 - Start the backend API:
cd backend
npm startThe backend will run on http://localhost:3001
Terminal 2 - Start the frontend dev server:
cd frontend
npm run devThe frontend will run on http://localhost:5173 (or another port if 5173 is taken)
Open your browser and navigate to:
http://localhost:5173
- Click on any lesson in the sidebar to start learning
- Read the lesson content and examples
- Write code in the editor
- Click "Run Code" to execute and see the output
- For exercises, click "Submit Solution" to validate your answer
- Navigate between lessons using the Previous/Next buttons
- Tutorial: Learn concepts with examples and practice code
- Exercise: Solve coding challenges with automated tests
Your progress is automatically saved to your browser's localStorage. You can:
- See completed lessons marked with a checkmark (✓)
- View overall progress percentage in the top bar
- Reset all progress using the "Reset Progress" button
GET /health
Returns the API status.
POST /api/execute
Content-Type: application/json
{
"code": "puts 'Hello, World!'",
"testCode": "# Optional test code"
}
POST /api/validate
Content-Type: application/json
{
"code": "def add(a, b)\n a + b\nend",
"tests": "raise 'Failed' unless add(2, 3) == 5"
}
-
Ruby Basics
- Introduction to Ruby
- Variables and Data Types
- Numbers and Math
- String Methods
-
Control Flow
- If Statements
- Loops (while, for, times, each)
- FizzBuzz Challenge
-
Arrays and Hashes
- Working with Arrays
- Array Methods
- Hash Basics
-
Methods
- Defining Methods
- Parameters and Return Values
- Calculator Exercise
-
Introduction to Rails
- What is Ruby on Rails?
- MVC Architecture
- Rails Application Structure
-
Routing
- Basic Routes
- RESTful Resources
- Route Parameters
-
Models and ActiveRecord
- ActiveRecord Basics
- CRUD Operations
- Validations
- Associations
-
Controllers and Views
- Controllers
- Actions
- Views and ERB
- Layouts
- Open
frontend/src/data/rubyLessons.jsorrailsLessons.js - Add a new lesson object to the appropriate section:
{
id: 'unique-lesson-id',
title: 'Lesson Title',
content: `# Markdown content here`,
starterCode: 'puts "starter code"',
solution: 'puts "solution"',
tests: '# Optional test code',
type: 'tutorial' // or 'exercise'
}Edit frontend/src/App.css to customize the appearance. The color scheme is based on GitHub's dark theme.
Frontend:
cd frontend
npm run buildBackend: The backend runs as-is in production. Consider adding:
- Docker containerization for Ruby code execution
- Rate limiting
- Authentication
- Code execution sandboxing
Current Implementation:
- 5-second timeout on code execution
- 1MB output buffer limit
Recommended for Production:
- Docker containers for code execution
- Resource limits (CPU, memory)
- Input sanitization
- Rate limiting
- User authentication
- Code execution sandboxing (firejail, nsjail)
- Add more Ruby lessons (Classes, Modules, Metaprogramming)
- Add more Rails lessons (Forms, Authentication, Testing)
- Implement user accounts and cloud progress sync
- Add code execution in Docker containers
- Add syntax highlighting in lesson content
- Add code snippets library
- Add community solutions sharing
- Add difficulty levels
- Add achievement badges
- Add hints system
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by RubyMonk
- Built with Monaco Editor
- UI design inspired by GitHub
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue if your problem isn't already listed
- Provide as much detail as possible
The sidebar shows all available lessons organized by topic, with the code editor and lesson content in the main area.
Submit your solutions and get instant feedback on whether your code passes the tests.
Track your learning journey with the built-in progress bar and completion markers.
Happy Learning! 🚀
Built with ❤️ for Ruby and Rails learners everywhere.