How harminderbomrah/jira-engine works
Project Type and Purpose
• This is a Ruby on Rails Engine packaged as a gem (“jira”) that you mount into a host Rails application.
• Its purpose is to integrate Jira (and a “CodeGiant” system) data into a Rails app, providing UI pages, background sync jobs, models, and services.
High-Level Architectural Components
a. Host Rails Application
• Your main app that includes this engine via Gemfile.
• Provides the database, routing, asset pipeline, and Sidekiq/ActiveJob infrastructure.
b. Jira Engine (the gem)
• Namespace: lib/jira/engine.rb mounts under /jira.
• Contains:
– MVC layers (app/controllers/jira, app/models/jira, app/views/jira).
– Services (app/services/jira/*) for HTTP/GraphQL calls.
– Background Jobs (app/jobs/jira/*) for periodic data sync.
– Mailers (app/mailers/jira/*) for notifications.
– Asset pipeline (app/assets/*) for JS/CSS/images.
c. External Services
• Jira REST (or GraphQL) API
• CodeGiant GraphQL endpoint
d. Database
• Tables for users, projects, issues, comments, histories, field_mappings, import_statuses, priorities, statuses, types, and mappings between Jira/CodeGiant and local users/projects.
e. Sidekiq (or ActiveJob)
• Processes background jobs that fetch and update data asynchronously.
f. OmniAuth (config/initializers/omniauth.rb)
• Handles Jira authentication workflow.
Relationships & Data Flow
1. User → UI
• User hits routes under /jira served by Jira::PagesController, ProjectsController, etc.
• Views render data by querying local models.
2. Controller → Service → External API
• Controllers call Jira::JiraProjectService or GraphqlService for on-demand data.
3. Scheduled/Synchronous Job → Service → Database
• Jobs (FetchJiraIssuesJob, FetchCodeGiantUsersJob, etc.) invoke service objects, pull data from external APIs, then upsert into ActiveRecord models (Issue, Project, User, etc.).
4. Persistence
• All entities are stored in the host app’s database via ActiveRecord migrations under db/migrate.
5. Notifications
• When certain events occur (issue mapped, import completed), mailers send out emails via Jira::ApplicationMailer.
Architectural Patterns & Design Principles
• Rails Engine Pattern: Clean isolation of “jira” functionality, mountable gem.
• MVC: Standard Rails model–view–controller separation within the engine.
• Service Objects: Encapsulate external API interactions in app/services/jira/*.
• Background Processing: Jobs for retryable, scheduled syncing.
• Dependency Injection/Configuration: Initializers for OAuth, Sidekiq, and asset precompile.