How rsv-ink/ink_components works
Project type and purpose
• InkComponents is an open-source Ruby gem that implements a design system for Rails using ViewComponent.
• It functions as a Rails Engine, packaging a library of UI components (built with Flowbite/Tailwind) that host applications can install and render via helper methods.
File structure
• Top-level:
• app/ → Rails Engine’s MVC-style structure
• lib/ → Engine definition, version, installers, rake tasks
• config/ → Routes, engine mounting, initializers
• app/assets & app/javascript → CSS (Tailwind) and JS entry for component assets
• spec/dummy/ → A dummy Rails app used to exercise and preview the engine
• spec/ → RSpec test suite for engine and components
• docs/ → Usage and integration guides
• Key patterns:
• Rails Engine (lib/ink_components/engine.rb)
• Component-based UI (app/components) using ViewComponent
• Asset pipeline integration (app/assets, tailwind.config.js, package.json)
• Generators & installers (lib/install, rake tasks) for host-app integration
Insights from README
• Describes the gem’s purpose: provide reusable Flowbite components.
• Installation generates Tailwind config, mounts the engine, and builds CSS.
• Offers a “Lookbook Preview” served by the dummy app at /ink_components/lookbook.
a. Main components
• Host Rails Application
• InkComponents Engine (the gem)
– ViewComponent-based UI components
– Asset definitions (Tailwind CSS, JavaScript)
– Generators & Rake tasks
– Engine routes (Lookbook preview)
• Asset Build Pipeline
– Tailwind CLI (yarn build:css)
– Webpacker / importmap (app/javascript)
• Test Harness
– RSpec suite
– Dummy Rails app for integration and Lookbook
b. Relationships and interactions
• Host App “requires” the gem → Bundler loads lib/ink_components/engine.rb
• Engine mounts its routes into the host (e.g., /ink_components/lookbook)
• Host views call helper wrappers → invoke ViewComponent render methods
• Asset build process pulls in engine’s Tailwind config & CSS into host’s build
• Rake tasks & generators scaffold configuration in host (tailwind.config.js)
• Tests exercise components inside a dummy app simulating a real host
c. Architectural patterns and principles
• Rails Engine modularity: self-contained plugin with its own MVC and assets
• Component-oriented UI via ViewComponent for encapsulation and reusability
• Generator pattern for seamless host-app integration
• Asset pipelining with Tailwind and standard Rails asset conventions
d. Key technologies/frameworks
• Ruby on Rails Engine
• ViewComponent gem
• Tailwind CSS (via yarn & tailwind.config.js)
• RSpec & dummy Rails app for testing
• Lookbook for live component previews
Final advice
• Every logical module: components library, asset config, installers, tests
• Don’t overcomplicate: represent each folder/group as a component if it has its own responsibility