How yashsharma1101/cricket-auction-app works
Project Type and Purpose
• This is a full-stack web application built with Ruby on Rails (MVC).
• It manages Users, Teams, Matches, and Admins; sends emails via Action Mailer; stores assets (Active Storage + Cloudinary); provides real-time features via Action Cable; and runs background jobs via Active Job.
File Structure for Architectural Components
• app/controllers, app/models, app/views → MVC layers.
• app/assets, app/javascript/packs → Frontend assets & JavaScript (Webpacker/Yarn).
• app/channels → WebSocket channels (Action Cable).
• app/jobs → Background tasks (Active Job, queued in Redis/Sidekiq or default).
• app/mailers → Email generation (SMTP or external).
• config/routes.rb → HTTP and WebSocket entry points.
• config/database.yml, db/migrate → Relational database (e.g., PostgreSQL).
• config/storage.yml, config/cloudinary.yml → File storage (Cloudinary or S3).
• bin/webpack, config/webpack/* → JS build pipeline.
• config/environments → Environment-specific settings.
• Gemfile → Ruby gem dependencies.
• package.json → NPM/Yarn dependencies.
• Rakefile → Build & maintenance tasks.
• render.yaml → Deployment configuration (Render.com).
Core System Components
a. Client (Web Browser / JS)
• Sends HTTP(S) requests.
• Connects via WebSockets for real-time updates.
b. Web Server & App Server
• Puma serving Rails Rack app (config.ru).
• Routes to controllers.
c. Rails MVC
• Controllers handle business logic.
• Models (Active Record) interact with the database.
• Views render HTML/JSON.
d. Database
• PostgreSQL (or configured SQL DB).
e. File Storage
• Active Storage pointing to Cloudinary (configured in storage.yml & cloudinary.yml).
f. Asset Pipeline & Bundler
• Sprockets (app/assets) + Webpacker (app/javascript) for CSS/JS.
g. Background Processing
• Active Job enqueues mailers (MailerJob) and other jobs to a queue backend (e.g., Redis/Sidekiq).
h. Action Mailer
• Sends transactional emails (AccessFormMailer, AuctionMailer).
i. Action Cable
• Real-time channels (app/channels) over Redis (pub/sub) for live updates (e.g., bidding sounds).
j. External Services
• Cloudinary for media.
• SMTP provider for email.
• Redis for caching/Action Cable / job queue.
• Optional: CDN for static assets.
k. Deployment
• Render.com (render.yaml), Docker or native builds via bin/render-build.sh.
Relationships and Data Flow
• Browser → HTTP → Puma → Rails Router → Controller → Model → Database → Model → Controller → View → Browser.
• Browser → WebSocket → Action Cable Server → Channel → Broadcast → Browser.
• Controller enqueues background jobs for heavy tasks or emails.
• Jobs run asynchronously, interacting with DB, Storage, Mailer.
• Active Storage handles file I/O to Cloudinary.
• Gems and npm packages support various subsystems (authentication, admin UI, asset compilation).
Architectural Patterns & Design Principles
• MVC for clear separation of concerns.
• Service-oriented within Rails: Mailers, Jobs, Channels as distinct services.
• Convention over configuration—standard Rails directory layout.
• Modular assets: separation of Sprockets assets vs. Webpacker packs.
• Namespaced admin area (app/controllers/admin, app/views/admin).
• Use of concerns to share code.
1. Sketch the browser at the left, splitting HTTP vs. WebSocket.
• Web Server (Puma)
• Router & Controllers
• Models & Active Record
• Views & Asset Server
• Channels & Jobs & Mailers
4. Storage (Cloudinary) connected to Active Storage.
5. External SMTP service linked to Action Mailer.
6. Build-time step: Yarn/Webpack → compiled JS/CSS output to app/public/assets.
7. Admin namespace (ActiveAdmin assets, admin controllers/views).