This is a Twitter clone for study purposes. It's a proof of concept on how to structure a rails project with minimal dependencies and set up for fast development and healthy and scalable growth.
Plain old boring rails 7 with Postgresql with turbo and stimulus for frontend SPA behavior and user experience enhancement. Tailwind CSS for no css at all and ViewComponent to replace rails partials.
Based on the checks pattern implement the WholeValue
pattern (lives inside app/values
) to separate user input data from object modeling.
Still based on the pattern above avoid using default ruby types like strings to
represent meaningful domain models. Example, in the Tweet
model the content
is not represented by a string. Instead is represented by its own class
Tweet.new(content: 'Hello there')
=> <Tweet:0x00007fef793705f8, content: TweetContent(Hello there)>
No checks for current_user
exemplify it.
User god models are a misrepresentation of how users actually interacts with the system.
No ActiveRecord
chains scattered in models/controllers. See this article for a detailed example.
Make rails view layer more sane (In probation yet)
-
Requirements Install Postgresql for db and libvips (or imagemagick) for image processing.
-
Configure the application
./bin/setup
- Run local services
# Run the services
./bin/dev
- Editing profile fields should reflect instantly on the sidebar;
- Posting/Liking a tweet will update followers feeds on the fly;
cloniter.mov
- Run an individual test with
rails test test/path/to/test_file
- Run the full suit
rails test:all