- Features
- Technical Design
- Database Schema
- Setup & Installation
- Running Tests
- Deployment
- Contributing
- License
- Authentication: Secure registration, login, logout, password reset, and account email activation.
- Microposts: Users can create, display, and delete tweets (microposts) with optional image uploads.
- User Profiles: View user info, avatar (Gravatar), micropost count, and follow/follower stats.
- Feed: Personalized feed showing own and followed users' posts.
- Follow System: Follow/unfollow users, see followers/following lists and counts.
- Responsive UI: Mobile-ready, Twitter-inspired design using SCSS.
- Email Notifications: Activation and password reset emails via ActionMailer.
- Docker Support: Containerized for easy local development and deployment.
- MVC Structure: Rails models for Users, Microposts, Relationships; RESTful controllers and ERB views.
- Authentication: Secure password handling with bcrypt, persistent sessions, and token-based account activation.
- Microposts: Text (max 140 chars), optional image uploads via ActiveStorage, ordered by most recent.
- Feed Algorithm: User feed combines own microposts and posts from followed users, efficiently indexed.
- Follow System: Self-referential Relationship model tracks who follows whom; bi-directional associations for followers and following.
- Frontend: Uses Hotwire (Turbo/Stimulus) for fast, real-time updates; Importmap for JS management.
- Styling: Custom SCSS for layouts, user lists, microposts, stats, and responsive design.
- Mailer: ActionMailer for email delivery; mailer previews for development.
- Docker: Multi-stage Dockerfile for building, assets precompilation, and lightweight runtime.
- User
- Has many microposts (dependent destroy)
- Has many active and passive relationships (for follows/followers)
- Validations: name, email (format, uniqueness), password
- Authentication: password_digest, remember/activation/reset tokens
- Micropost
- Belongs to user
- Validates content length and presence
- Supports image attachment (ActiveStorage)
- Relationship
- Belongs to follower and followed (User)
- Enforces unique follower-followed pairs
users
ββ id : PK
ββ name : string
ββ email : string (unique)
ββ password_digest : string
ββ remember_digest : string
ββ admin : boolean
ββ activation_digest : string
ββ activated : boolean
ββ activated_at : datetime
ββ reset_digest : string
ββ reset_sent_at : datetime
ββ timestamps
microposts
ββ id : PK
ββ content : text
ββ user_id : FK β users.id
ββ created_at, updated_at
ββ indexes: [user_id, created_at]
relationships
ββ id : PK
ββ follower_id : FK β users.id
ββ followed_id : FK β users.id
ββ timestamps
ββ unique index: [follower_id, followed_id]
(active_storage tables for images)
- Ruby (>= 3.2), Bundler
- Node.js & Yarn (if working with assets)
- Docker (optional)
- SQLite3 (default; swap for PostgreSQL/MySQL as needed)
git clone https://github.com/amrhossamdev/twitter-clone.git
cd twitter-clone
gem install bundler
bundle install
bin/rails db:setup
bin/rails db:seed # (optional: loads sample users and microposts)
bin/rails server
# Visit http://localhost:3000docker build -t twitter-clone .
docker run -p 3000:3000 twitter-clonebin/rails testIncludes model, controller, and integration tests for core features.
- Prepare assets and environment variables as needed.
- Use Docker or standard Rails deployment.
- Email delivery requires SMTP configuration.
- Fork the repo and clone locally.
- Create a feature branch (
git checkout -b feature-branch) - Commit your changes (
git commit -am 'Add feature') - Push and open a Pull Request.
MIT
Inspired by the Ruby on Rails Tutorial, Michael Hartl, and Twitterβs feature set.
For questions or issues, open a GitHub issue.