How sfarrukh/rails-crud works
Project Type and Purpose
• This is a full-stack Ruby on Rails monolithic web application implementing an online rental store.
• Frontend: ERB views + CoffeeScript/JavaScript + CSS under app/assets.
• Backend: MVC Rails app (app/controllers, app/models).
• Persistence: MySQL (Sakila + custom tables).
• Real-time: ActionCable channels.
• Asynchronous jobs/mail: ActiveJob and ActionMailer.
File Structure
• Top-level rails conventions: app/, config/, db/, lib/, public/, test/, vendor/.
• app/ is subdivided into:
• assets: JS/Coffee, CSS, images.
• controllers: namespaced by ‘admin’, ‘staff’, ‘api’, ‘account’, plus public controllers.
• models: domain entities (Actor, Film, Customer, Rental, etc.).
• views: ERB templates aligned with controllers.
• channels: ActionCable WebSocket endpoints.
• jobs & mailers: background-job and email functionality.
• config/: routing (config/routes.rb), database config, environment setups, initializers.
• db/: migrations, schema, seeds.
• Public/API endpoints:
• Web UI for Public, Staff, Admin.
• JSON API under app/controllers/api.
• Tests mirror controllers/models via test/.
README for Architecture Insights
• Three user-roles/environments with separate login flows: public, staff, admin.
• Uses Sakila schema plus four custom tables (Admin, Staff, CustomerPaymentInfo, RentalPending).
• Domain relationships via ActiveRecord associations.
a. Main Components
• Users (three types): Public user, Staff user, Admin user.
• Client (Browser/SPA): Requests HTML pages, static assets, JSON API.
• Web Server Layer: NGINX (optional), Puma (Rails app server).
• Rails Monolith:
• Router (config/routes).
• Controller Layer (app/controllers + namespaces: public, admin, staff, api).
• View/Asset Pipeline (ERB, JS, CSS).
• Model Layer (ActiveRecord models).
• ActionCable Server (WebSocket channels).
• Background Job Processor (ActiveJob, e.g., Sidekiq or default inline).
• Mailer (ActionMailer).
• Database: MySQL with Sakila + custom tables.
• External Services: SMTP server for emails.
b. Relationships and Interactions
• Users → HTTP/WebSocket → Rails Router.
• Router → appropriate Controller namespace (public, staff, admin, api).
• Controllers ↔ Models (ActiveRecord ORM).
• Models → MySQL (CRUD operations, foreign-key relationships).
• Controllers → Views/JSON responses.
• Asset Pipeline serves JS/CSS.
• Controllers/jobs → ActionMailer → SMTP.
• Controllers/jobs → ActiveJob → job queue.
• Clients can open WebSocket connections to ActionCable channels.
• Admin/Staff UIs talk to JSON API via AJAX scripts in app/assets/javascripts.
• All traffic goes through Web Server → Puma app server → Rails app.
c. Architectural Patterns & Design Principles
• MVC (Model–View–Controller).
• Namespace-based routing (public, admin, staff, api).
• RESTful controllers plus JSON API endpoints.
• Asset Pipeline for static assets.
• ActiveRecord associations for relational mapping.
• ActionCable for real-time features.
• Background jobs for long-running tasks (mail, data processing).
• Three-tier separation: Presentation (views/assets), Application (controllers/models/jobs), Data (MySQL).
d. Key Technologies/Frameworks/Libraries
• Ruby on Rails (MVC, ActiveRecord, ActionCable, ActiveJob, ActionMailer).
• MySQL (Sakila schema + custom tables).
• Puma application server.
• Web server (NGINX or Apache).
• CoffeeScript/JavaScript for client-side logic.
• CSS/bootstrap for styling.
• Sidekiq (optional) or default ActiveJob adapter.
• SMTP/SendGrid (or other) for email.
Elements
• Clear labels for each component (e.g., “Puma Server”, “app/controllers/admin”, “MySQL (sakila + custom tables)”).
• Namespaces: public, api, admin, staff controllers.
• Major tables/entities if desired: Customer, Film, Rental, RentalPending, Admin, Staff.