How sergiy17/classes_scheduler works
Main Components
a. Client Layer
• Browser / PWA (HTML/ERB views, Stimulus controllers via Importmap)
• PDF viewer (or PDF download endpoint)
b. Web/Application Layer
• HTTP server: Puma → Rack → Rails router (config/routes.rb)
• Controllers (app/controllers/*)
• Views & Assets (app/views, app/assets, app/javascript)
• Service objects (app/services/schedule_pdf_service.rb)
• Serializers (app/serializers/*.rb)
c. Business/Data Layer
• Models / ActiveRecord (app/models/*.rb)
• Database: PostgreSQL (config/database.yml)
• Associations: Student ↔ Section (via student_section), Teacher, Classroom, Subject
d. Background Processing
• ActiveJob (app/jobs) → queue adapter (config/queue.yml)
• Recurring jobs (config/recurring.yml)
e. Real-Time / WebSockets
• ActionCable (config/cable.yml)
f. Storage & Caching
• File storage for PDF, ActiveStorage if enabled (config/storage.yml)
• Cache store (config/cache.yml)
g. Mailers
• ActionMailer (app/mailers) for notifications
h. External/DevOps
• Redis (if used for cache or as queue backend)
• SMTP provider
• Docker container (Dockerfile + .kamal deployment hooks)
• CI/CD (GitHub Actions: .github/workflows/ci.yml)
Relationships & Data-Flows
• Within Rails, show the request entering the Router and going to the StudentsController (for /students/:id or /students/:id/schedule_pdf).
• Controller calls:
• ActiveRecord models to read/write DB → PostgreSQL
• schedule_pdf_service to assemble schedule PDF → file storage → response to client
• Optionally queues jobs via ActiveJob → Queue backend → Workers → Models/Services
• For PWA features, show service-worker fetching assets from the same Rails app.
• For WebSockets, show client ↔ ActionCable server ↔ Rails channels.
• For mailers, show ApplicationMailer sending via SMTP.
Architectural Patterns & Principles
• MVC pattern: clear separation of Controllers, Views, Models
• Service-object pattern for complex business logic (PDF generation)
• Importmap + Stimulus for progressive enhancement on the front end
• ActiveJob for asynchronous processing and scheduled tasks
• Single monolithic codebase, but logically modularized via directories (controllers, models, services, serializers)
• Use of Rails initializers (config/initializers) for cross-cutting concerns (CSP, inflections, asset compilation)
Final Checklist of Elements
• Clear component grouping: Client, Web, MVC, Services, Data, Jobs, External
• Labels for all major frameworks & technologies (Ruby 3.x, Rails 7, Stimulus/Importmap, Puma, PostgreSQL, Redis, Docker)
• A small note on deployment: Docker container managed by Kamal, CI via GitHub Actions