MotosCat is a comprehensive motorcycle social networking platform built with Ruby on Rails 8, designed specifically for the Catalan motorcycle community. This repository contains the development environment for the live production site at motos.cat.
π Live Site: https://motos.cat π¦ Repository: Development environment on Debian/RVM
- Overview
- Features
- Tech Stack
- Getting Started
- Development
- Project Structure
- Configuration
- Testing
- Deployment
- Contributing
- License
MotosCat combines social networking, ride organization, e-commerce, and subscription management into a single comprehensive platform for motorcycle enthusiasts in Catalunya. Built with modern Ruby on Rails 8 and featuring full bilingual support (Catalan/English).
- Production-Ready: Live at motos.cat serving the Catalan motorcycle community
- Modern Stack: Rails 8.0, Ruby 3.4.3, MySQL, Redis, Tailwind CSS 4.0
- Payment Processing: Full Stripe integration with subscriptions and webhooks
- Multilingual: Complete Catalan and English translations
- Responsive Design: Mobile-first Tailwind CSS with modern UI components
- Background Jobs: Sidekiq for async processing and scheduled tasks
- Secure Authentication: Devise-based with encrypted sessions
- User Profiles: Customizable profiles with avatar uploads
- Subscription Plans: Multiple tiers (Free, Premium, VIP) with Stripe billing
- Scoring System: Automated weekly engagement scoring (PuntuaciΓ³)
- Admin Panel: Comprehensive dashboard for user and content management
- Event Creation: Full-featured ride event management
- GPS Integration: GPX file upload and route visualization
- Payment System: Optional ride fees with Stripe checkout
- OBERTA/TANCADA: Free (β¬1) and premium ride types
- Inscription Management: Track participants and payment status
- Real-time Updates: Turbo-powered live updates
- Rich Posts: Text, images, and file attachments
- Social Interactions: Like, comment, and follow system
- Activity Feed: Personalized feed based on follows
- Notifications: Email notifications for all interactions
- Polymorphic Likes: Like posts, rides, and comments
- Product Catalog: Motorcycle gear and accessories
- Shopping Cart: Session-based cart with persistence
- Stripe Payments: Secure one-time and recurring payments
- Donation System: Support platform (β¬5-β¬100)
- Webhook Processing: Real-time Stripe event handling
- Email Confirmations: Automated receipts
- Bilingual Support: Complete Catalan and English translations
- Localized Content: Time zones, dates, currency (EUR)
- Dynamic Language Switching: User-selectable locale
- Time Zone: Europe/Paris (CET/CEST for Catalunya)
- Tailwind CSS 4.0: Utility-first responsive design
- Radix UI: Accessible component primitives
- Stimulus.js: Progressive JavaScript enhancement
- Turbo: SPA-like navigation without complex JS
- React Components: Modern UI elements with shadcn/ui
- Ruby 3.4.3 - Programming language
- Rails 8.0 - Web application framework
- MySQL/MariaDB - Primary database
- Redis - Caching and session store
- Sidekiq - Background job processing
- Stripe - Payment processing platform
- Devise - Authentication solution
- Tailwind CSS 4.0 beta - Utility-first CSS framework
- Stimulus.js - JavaScript framework
- Turbo - Fast navigation framework
- React 18 - Component library
- Radix UI - Accessible primitives
- FontAwesome - Icon library
- Flowbite - UI components
- RuboCop - Ruby code linter
- Brakeman - Security scanner
- ESLint - JavaScript linter
- Prettier - Code formatter
- Jest - JavaScript testing
- SimpleCov - Test coverage
- Webpack - Module bundler
- Apache 2.4.62 - Web server
- Passenger - Application server
- Let's Encrypt - SSL certificates
- Debian 12 - Operating system
- RVM 1.29.12 - Ruby version manager
- GitHub Actions - CI/CD (optional)
Ensure you have the following installed:
- Ruby 3.4.3 - Use RVM or rbenv
- Rails 8.0+ - Latest stable version
- MySQL/MariaDB 10.5+ - Database server
- Node.js 18+ - JavaScript runtime
- npm 11+ - Package manager
- Redis 6+ - Cache server
- ImageMagick - Image processing
- OS: Linux (Debian/Ubuntu), macOS, or Windows WSL2
- Memory: 4GB+ RAM (development), 8GB+ (production)
- Storage: 20GB+ available space
- Network: Stable internet for package downloads
-
Clone the repository
git clone git@github.com:coopeu/mc.git cd mc -
Install Ruby with RVM
# If RVM not installed curl -sSL https://get.rvm.io | bash source ~/.rvm/scripts/rvm # Install Ruby 3.4.3 rvm install 3.4.3 rvm use 3.4.3 --default # Verify installation ruby -v # Should show 3.4.3
-
Install dependencies
# Install Ruby gems bundle install # Install Node packages npm install
-
Database setup
# Create database rails db:create # Run migrations rails db:migrate # Load seed data (optional) rails db:seed
-
Configure credentials
# Edit Rails credentials EDITOR=nano rails credentials:editAdd the following structure:
stripe: publishable_key: pk_test_... secret_key: sk_test_... webhook_secret: whsec_... recaptcha: site_key: your_recaptcha_site_key secret_key: your_recaptcha_secret_key # Database credentials (production only) username: motos_cat_user password: secure_password_here
-
Start development servers
# Terminal 1: Rails server rails server # Terminal 2: Redis (if not running as service) redis-server # Terminal 3: Sidekiq background jobs bundle exec sidekiq # Terminal 4: Tailwind CSS watcher (optional) npm run build:css -- --watch
-
Access the application
http://localhost:3000
# Check database connection
rails runner "puts 'Database: ' + (ActiveRecord::Base.connection.active? ? 'OK' : 'FAILED')"
# Check Redis connection
rails runner "puts 'Redis: ' + (Redis.new.ping == 'PONG' ? 'OK' : 'FAILED')"
# Check Stripe configuration
rails runner "puts 'Stripe: ' + (Stripe.api_key.present? ? 'OK' : 'MISSING')"# Start all services
bin/dev # Rails + Tailwind watcher
# Individual services
rails server # Rails on port 3000
bundle exec sidekiq # Background jobs
redis-server # Cache/sessionsrails db:migrate # Run migrations
rails db:rollback # Rollback last migration
rails db:seed # Load seed data
rails db:reset # Drop, create, migrate, seed
rails console # Interactive console
rails runner "User.count" # Run Ruby codenpm run build # Development build
npm run build:prod # Production build
npm run build:css # Tailwind CSS compilation
rails assets:precompile # Precompile all assets# Ruby
bundle exec rubocop # Check Ruby style
bundle exec rubocop -a # Auto-fix issues
# JavaScript
npm run lint # ESLint check
npm run lint -- --fix # Auto-fix JS issues
npm run format # Prettier formatbundle exec brakeman # Security vulnerabilities
bundle exec bundler-audit # Dependency auditnpm run type-check # TypeScript validation# Start Sidekiq
bundle exec sidekiq
# Monitor jobs
bundle exec sidekiq -C config/sidekiq.yml
# Redis CLI for debugging
redis-cli monitormc/
βββ app/
β βββ controllers/ # 25+ REST controllers
β β βββ admin/ # Admin dashboard
β β βββ charges_sortides_controller.rb
β β βββ charges_donations_controller.rb
β β βββ subscriptions_controller.rb
β β βββ webhooks_controller.rb
β β
β βββ models/ # 30+ ActiveRecord models
β β βββ concerns/ # FileValidatable, Likeable
β β βββ user.rb # Devise authentication
β β βββ sortide.rb # Ride events
β β βββ piulade.rb # Social posts
β β βββ puntuacio.rb # Scoring system
β β
β βββ services/ # Business logic
β β βββ stripe_service.rb
β β βββ analytics_service.rb
β β βββ sortide_pricing_service.rb
β β βββ rider_position_service.rb
β β
β βββ jobs/ # Background processing
β β βββ puntuacio_setmanal_job.rb
β β βββ daily_admin_summary_job.rb
β β
β βββ mailers/ # Email notifications
β β βββ user_mailer.rb
β β βββ admin_mailer.rb
β β
β βββ javascript/ # Frontend code
β βββ components/ # React components
β βββ contexts/ # React contexts
β βββ controllers/ # Stimulus controllers
β
βββ config/
β βββ routes.rb # 100+ routes
β βββ database.yml # DB configuration
β βββ credentials.yml.enc # Encrypted secrets
β βββ locales/ # i18n translations
β β βββ ca.yml # Catalan
β β βββ en.yml # English
β βββ initializers/
β
βββ db/
β βββ migrate/ # Database migrations
β βββ schema.rb # Current schema
β βββ seeds.rb # Seed data
β
βββ test/ # 150+ tests
β βββ controllers/ # Integration tests
β βββ models/ # Unit tests
β βββ system/ # E2E tests
β βββ integration/ # Payment flows
β βββ support/ # Test helpers
β
βββ scripts/ # Automation scripts
βββ public/ # Static assets
βββ storage/ # Active Storage files
βββ vendor/ # Third-party code
- Gemfile - Ruby dependencies
- package.json - JavaScript dependencies
- Dockerfile - Container configuration
- tailwind.config.js - Tailwind CSS configuration
- webpack.config.js - Webpack bundler config
- Rakefile - Rake tasks
Production credentials are encrypted in config/credentials.yml.enc:
# Edit production credentials
EDITOR=nano RAILS_ENV=production rails credentials:editRequired structure:
# Stripe (REQUIRED for payments)
stripe:
publishable_key: pk_live_...
secret_key: sk_live_...
webhook_secret: whsec_...
# Database (production)
username: motos_cat_user
password: secure_password
# SMTP (email)
SMTP_USERNAME: notifications@motos.cat
SMTP_PASSWORD: smtp_password
# Security
secret_key_base: (auto-generated)
# Optional services
recaptcha:
site_key: ...
secret_key: ...
redis_url: redis://localhost:6379/0For development, create .env file:
STRIPE_PUBLISHABLE_KEY=pk_test_...
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
DATABASE_URL=mysql2://root:password@localhost/mc_development
REDIS_URL=redis://localhost:6379/0- Create account at stripe.com
- Get API keys from Dashboard β Developers β API keys
- Configure webhook:
- URL:
https://yourdomain.com/webhook/stripe - Events:
checkout.session.completed,invoice.payment_succeeded,customer.subscription.updated
- URL:
- Sync plans:
rails runner "Plan.sync_with_stripe"
# Run all tests
rails test # Full suite
rails test:models # Unit tests
rails test:controllers # Integration tests
rails test:system # E2E tests
# Specialized suites
rails test:stripe # Payment flows
rails test:security # Security validation
rails test:comprehensive # Full with coverage
# JavaScript tests
npm test # Jest suite
npm run test:watch # Watch mode
npm run test:coverage # Coverage report# Run tests with coverage
rails test:comprehensive
# View HTML report
open coverage/index.htmlUse Stripe test mode:
- Test Card:
4242 4242 4242 4242 - Expiry: Any future date
- CVC: Any 3 digits
- ZIP: Any 5 digits
Live Site: motos.cat
- Hosting: HOSTIKA.lt (Lithuania)
- Stack: Debian 12 + Apache 2.4.62 + Passenger
- Ruby: 3.4.3 (via RVM)
- Rails: 8.0
- Database: MySQL/MariaDB
- SSL: Let's Encrypt
- Directory:
/var/www/html/motos.cat
-
Server preparation
sudo apt update && sudo apt upgrade -y sudo apt install -y ruby-dev nodejs npm mysql-server redis-server \ imagemagick apache2 libapache2-mod-passenger -
Install RVM & Ruby
curl -sSL https://get.rvm.io | bash rvm install 3.4.3 rvm use 3.4.3 --default -
Deploy application
cd /var/www/html git clone git@github.com:coopeu/mc.git motos.cat cd motos.cat bundle install --deployment --without development test npm install --production RAILS_ENV=production rails db:migrate RAILS_ENV=production rails assets:precompile chown -R www-data:www-data .
-
Configure Apache
<VirtualHost *:443> ServerName motos.cat DocumentRoot /var/www/html/motos.cat/public PassengerRuby /home/user/.rvm/gems/ruby-3.4.3/wrappers/ruby PassengerAppEnv production SSLEngine on SSLCertificateFile /etc/letsencrypt/live/motos.cat/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/motos.cat/privkey.pem </VirtualHost>
-
Start Sidekiq
sudo systemctl enable sidekiq-motoscat sudo systemctl start sidekiq-motoscat
RAILS_ENV=production rails runner "puts 'Status: OK'"
RAILS_ENV=production rails runner "puts User.count"
curl -I https://motos.cat- CLAUDE.md - AI assistant guide
- DEVELOPMENT_SETUP.md - Dev environment
- PRODUCTION_SETUP.md - Production guide
- DEPLOYMENT_PROTOCOL.md - Deployment steps
- API_DOCUMENTATION.md - API reference
- File Upload Security: FileValidatable concern with MIME validation
- Payment Security: PCI-compliant Stripe integration
- Authentication: Devise with secure sessions
- Authorization: Role-based access control
- Input Validation: XSS and SQL injection prevention
- Security Headers: HSTS, CSP, X-Frame-Options
- Regular Scanning: Brakeman vulnerability detection
- Fork the repository
- Create feature branch:
git checkout -b feature/amazing-feature - Make changes and add tests
- Run test suite:
rails test:comprehensive - Check code quality:
bundle exec rubocop && npm run validate - Commit changes:
git commit -m "feat: add amazing feature" - Push to branch:
git push origin feature/amazing-feature - Create Pull Request
- Follow Rails conventions
- Add comprehensive tests
- Use FileValidatable for uploads
- Consider database query performance
- Use Catalan naming for domain concepts
This project is licensed under the MIT License - see the LICENSE file for details.
- Ruby on Rails - Web framework
- Stripe - Payment processing
- Tailwind CSS - CSS framework
- Stimulus & Turbo - JavaScript frameworks
- Devise - Authentication
- shadcn/ui - UI components
- Sidekiq - Background jobs
- Email: coopeu@coopeu.com
- Website: motos.cat
- Issues: GitHub Issues
Built with β€οΈ for the Catalan motorcycle community