How wakeelmustafa/ecommerce-project works
Project type and purpose
• This is a full-stack Ruby on Rails e-commerce/demo application. It supports user authentication (Devise), product listings, shopping carts (LineItems), comments, coupons, Stripe payments, PDF/CSV exports, full-text search (Sphinx), and background jobs (Sidekiq/Delayed Job).
File structure
• Top-level:
• app/ (MVC: controllers, models, views, assets, channels, jobs, mailers, services, indices)
• config/ (Rails config, routes, initializers, environments, database, Sphinx, Sidekiq)
• db/ (migrations, schema, seeds, Sphinx data)
• lib/ (tasks, assets)
• bin/ (rails commands, webpack, yarn)
• spec/ & test/ (RSpec and Minitest suites)
• Patterns: MVC for request handling, Service Objects (app/services/stripe_services.rb), background jobs (app/jobs/ & config/initializers/sidekiq.rb & delayed_job), full-text index (app/indices/product_index.rb + config/dev/development.sphinx.conf).
• Deployment/build: Webpacker (config/webpack), Puma (config/puma.rb), Sidekiq (config/sidekiq.yml), environment configs.
Derive insights from README
• Generic placeholder README suggests standard Rails setup: Ruby version manager, bundle install, database create/migrate/seed, Sphinx index build, redis + Sidekiq, mailer config, Stripe keys, running tests, deployment via Capistrano/Heroku.
Main components & interactions
a. Frontend/client
• Browser (HTML/CSS/JS) served by Rails via Webpacker + asset pipeline
• Stimulus/ES6 packs (app/javascript/)
b. Rails Application (monolith)
• Controllers → Services/Models → Views
• ActionCable (app/channels) for any real-time features
• ActiveStorage for attachments (if used)
• Service Layer: StripeServices
• Indices: ProductIndex (Sphinx)
• Background Jobs:
– Sidekiq workers (config/sidekiq.yml + app/jobs)
– Delayed Job (for long running tasks like report emailing)
• Mailers: UserMailer, ReportMailer, ReportMailerPdfMailer
c. Data Stores
• PostgreSQL (config/database.yml)
• Sphinx (full-text search index)
• Redis (Sidekiq queue)
• (Optional) ActiveStorage service (local/filesystem/S3)
d. External Services
• Stripe (payment processing)
• SMTP/SendGrid (email delivery)
• (Potentially) CDN or Cloud Storage
Relationships & Data Flows
1. Browser → Rails app (HTTP requests to controllers)
2. Controllers → Models (ActiveRecord) ↔ PostgreSQL
3. Controllers → Views → Browser (HTML/JS/CSS)
4. Controllers/Services → Sphinx for search queries/index updates
5. Controllers/Services enqueue jobs → Sidekiq/Delayed Job → app/jobs → Mailers/Reports
6. Services (StripeServices) call Stripe APIs → payment confirmation → update DB
7. Mailers send emails via SMTP provider
Architectural patterns & design principles
• MVC (Model-View-Controller) at core
• Service Objects for third-party integrations (Stripe)
• Background Processing for long or asynchronous tasks (reports, emails)
• Full-text Search Index separated from relational DB (Sphinx)
• RESTful controllers for resources (products, carts, line_items, comments)
• Devise for authentication/authorization
• Webpack/Stimulus for modular JS
a. Controllers (products, carts, comments, users)
b. Models & Service Objects
c. Jobs & Mailers
d. Channels (ActionCable)
e. Webpacker/Assets
8. Optional: show ActiveStorage → Storage (local or S3).
9. Flows: “Add to cart → LineItem.create”, “Checkout → Stripe API → Job.enqueue → Email sent”.