Skip to content
forms-raw_singleitemedit-icon
navigation
modification_btn
docs
messages
flatprojectmap.handlebars
Plug-in - Maintenance Plans
modificationbutton
docs_htmltables.handlebars

Plug-in - Maintenance Plans

docs_html.handlebars
documentation.handlebars

1. Overview

1.1 Plugin Name

Albatross – an asset maintenance planning module.

1.2 Purpose

Albatross provides an Asset Maintenance Plan Registry and Maintenance Plan Dashboard for the Shiftbulk ecosystem:

  • A CRUD interface for defining maintenance plans at asset or system level (e.g. “Stacker reclaimer – mechanical maintenance plan”, “E-room fire protection maintenance plan”).
  • Each maintenance plan contains sub-items / component-level plan lines (e.g. “Gearbox oil change”, “Blocked chute probe functional test”, “Deluge valve inspection”).
  • Tight linkage to the Atlas asset hierarchy (Site → Area → Equipment / Asset).
  • Fields to capture frequency, task type, skill, duration and references at plan item level.
  • Status and revision tracking at plan header level (draft, active, superseded, archived).
  • A dashboard showing coverage and health of maintenance plans across sites, areas and assets.

Albatross integrates into the existing Shiftbulk app:

  • Express + Handlebars
  • Tailwind CSS (via parent layout)
  • MongoDB + Mongoose
  • Existing layout: views/albatross/main.handlebars (or main layout via 'main')

Key difference vs Osprey:
Osprey manages work orders (instances of work).
Albatross manages maintenance plans (templates/blueprints) that describe what should be done to an asset and its components over its life.

1.3 Mount Point

  • Plugin root router: plugins/albatross/index.js
  • Mount path in main app:
    const albatross = require('./plugins/albatross');
                        app.use('/albatross', albatross);
                        

2. Goals & Non-Goals

2.1 Goals

  1. Provide a central registry of asset maintenance plans with:

    • Plan title / short description
    • Full description / rationale
    • Status and criticality
    • Linkage to Atlas assets (site, area, equipment/asset)
    • Plan-level metadata (plan type, revision, source, references)
  2. Model component-level maintenance plan items inside each plan:

    • Component name / code
    • Task description and task type (inspection, service, test, replacement, etc.)
    • Frequency and interval (including custom interval days)
    • Estimated duration, skill/role and references (OEM manual ref, drawing, SOP)
    • Mandatory flag and active flag per item
  3. Provide a maintenance plan dashboard with:

    • Counts of plans by status (draft, active, superseded, archived)
    • Roll-ups by site and area, with drill-down to individual assets
    • Simple indicators for “coverage gaps” (assets with no active plan)
  4. Full CRUD for plans:

    • List
    • Create
    • Edit
    • View detail (including plan items)
    • Soft delete / archive (retaining history)
  5. Use Tailwind CSS and Shiftbulk main layout:

    • No Bootstrap classes in Albatross templates.
  6. Define everything clearly so an LLM can generate a complete plugin code tree and provide it as a downloadable zip for the user.

2.2 Non-Goals

  • No scheduling/execution logic for individual work events (that is Osprey’s role).
  • No automatic work order generation in v1 (linkage can be added later).
  • No advanced resource or capacity planning (we only store plan metadata).
  • No real-time / websocket updates; plain HTTP is sufficient.
  • No deep cross-plugin joins beyond basic Atlas references (IDs and names pulled from Atlas are sufficient).

4. Data Model

4.1 Mongoose Model: MaintenancePlan

File: plugins/albatross/models/MaintenancePlan.js
Collection naming: All collections must be prefixed with albatross_.
Collection name: albatross_maintenanceplans (default Mongoose naming).

Schema Fields

  • _id – ObjectId

Plan Header

  • title – String, required, max length ~200
    e.g. "Stacker Reclaimer SR01 – Mechanical Maintenance Plan".
  • description – String, optional, long text (overall plan rationale, scope, assumptions).
  • planType – String, enum: 'preventive' | 'predictive' | 'inspection' | 'statutory' | 'corrective_template' | 'mixed', default 'preventive'.
  • status – String, enum: 'draft' | 'active' | 'superseded' | 'archived', default 'draft'.
  • criticality – String, enum: 'low' | 'medium' | 'high' | 'critical', default 'medium'.

Atlas Asset Linkage (using Atlas collections as reference for the primary asset the plan applies to)

  • siteId – ObjectId, ref 'AtlasSite', nullable.
  • areaId – ObjectId, ref 'AtlasArea', nullable.
  • equipmentId – ObjectId, ref 'AtlasEquipment', nullable.
  • Denormalized display fields (kept in sync by controller logic):
    • siteName – String
    • areaName – String
    • equipmentName – String

Revision & Source

  • planCode – String, optional (e.g. "MP-SR01-MECH-001").
  • revision – String, optional (e.g. "Rev 0", "Rev 1").
  • revisionDate – Date, optional.
  • approvedBy – String or ObjectId, optional.
  • sourceDocument – String, optional (e.g. OEM manual reference, procedure number).
  • notes – String, optional (free-form comments).

Plan Items (Sub-Documents)
Each maintenance plan has an array of component-level plan items:

planItems: [
                      {
                        _id: ObjectId (auto),
                        componentCode: String,       // e.g. "GBX-01"
                        componentName: String,       // e.g. "Main gearbox"
                        taskDescription: String,     // e.g. "Check gearbox oil level and top up if required"
                        taskType: {
                          type: String,
                          enum: ['inspection', 'service', 'test', 'replacement', 'cleaning', 'lubrication', 'calibration', 'other'],
                          default: 'inspection'
                        },
                        isMandatory: { type: Boolean, default: true },
                    
                        // Frequency & Recurrence at item level
                        frequency: {
                          type: String,
                          enum: ['once', 'daily', 'weekly', 'monthly', 'quarterly', 'yearly', 'custom'],
                          default: 'monthly'
                        },
                        customIntervalDays: { type: Number, min: 1 },
                        defaultStartOffsetDays: { type: Number, min: 0 }, // offset from asset commissioning date or plan start
                    
                        // Execution-related metadata (for planning, not actual work events)
                        estimatedDurationHours: Number,
                        skillOrRole: String,         // e.g. "Mechanical fitter", "Instrumentation technician"
                        referenceDocs: [String],     // e.g. ["OEM-GBX-01-SECTION-5", "WI-MECH-010"]
                        safetyNotes: String,
                    
                        isActive: { type: Boolean, default: true },
                        sortOrder: Number
                      }
                    ]

Assignment & Tags (Plan-Level)

  • owner – String or ObjectId, optional (e.g. responsible engineer or planner).
  • tags – [String], optional (e.g. "fire-protection", "mechanical", "electrical").

Lifecycle Flags

  • isActive – Boolean, default true (soft delete / archive flag for the plan).

Timestamps

  • createdAt / updatedAt – Date (timestamps: true).

4.2 Maintenance Plan Aggregation Model (In Memory)

  • No separate DB model for aggregated dashboard metrics.
  • Aggregations are computed on the fly in the controller:
    • By status for high-level dashboard counts.
    • By siteId and areaId for location-based drill-down.
    • Optionally by equipmentId, planType or criticality for deeper analysis.
  • Helper function(s) derive:
    • Overall plan counts by status.
    • Simple “coverage” indicator, e.g.:
      • assets with at least one active plan
      • assets without any active plan (“gap”).

A simple derived health flag per site/area can be used:

  • 'good' – most critical assets have active plans, few gaps.
  • 'warning' – some critical assets missing active plans.
  • 'critical' – many critical assets missing plans or many plans still in draft.

5. Navigation & Routes

5.1 Router File

File: plugins/albatross/index.js
Exports an Express router.

5.2 Middleware

  • bodyParser.urlencoded({ extended: true })
  • bodyParser.json()
  • cookieParser and CSRF can be applied at the router level, consistent with other plugins.
  • Set res.locals.basePath = req.baseUrl || '/albatross' for URL generation in views.

5.3 Route List

Dashboard & Browsing

  • GET /albatross
    → Albatross Dashboard – global plan status summary and site/area roll-up.
  • GET /albatross/site/:siteId
    → Site-level view (plans associated with this site and its assets).
  • GET /albatross/site/:siteId/area/:areaId
    → Area-level detail view.
  • GET /albatross/equipment/:equipmentId
    → Asset-level detail view (maintenance plans for a specific asset).

Maintenance Plans CRUD

  • GET /albatross/plans
    → List view of all maintenance plans with filters.
  • GET /albatross/plans/new
    → New maintenance plan form.
  • POST /albatross/plans
    → Create maintenance plan (header + initial items).
  • GET /albatross/plans/:id
    → Maintenance plan detail page (including plan items).
  • GET /albatross/plans/:id/edit
    → Edit maintenance plan form (header + items).
  • POST /albatross/plans/:id or POST /albatross/plans/:id?_method=PUT
    → Update maintenance plan.
  • POST /albatross/plans/:id/delete or POST /albatross/plans/:id?_method=DELETE
    → Soft delete / archive (set isActive = false or status = 'archived').

Status / Lifecycle Actions (Optional Convenience)

  • POST /albatross/plans/:id/activate
    → Set status = 'active' (if validation passes).
  • POST /albatross/plans/:id/supersede
    → Set status = 'superseded' (and optionally link to a new plan via future field).

Optional Export Routes

  • GET /albatross/export/json
    → Return JSON of all maintenance plans (Content-Disposition: attachment).
  • GET /albatross/export/csv
    → Return CSV of maintenance plans and optionally plan items.

6. Controllers

File: plugins/albatross/controllers/albatrossController.js

(You may later split into dashboardController and plansController, but a single controller is acceptable for v1.)

6.1 Helper: summarizePlans(plans)

Input: Array of MaintenancePlan documents or simplified objects with .status.
Output:

{
                      counts: {
                        draft: Number,
                        active: Number,
                        superseded: Number,
                        archived: Number
                      },
                      total: Number,
                      health: 'good' | 'warning' | 'critical'
                    }
                    

Logic

  • Initialise counts for each status to zero.
  • Iterate through plans and increment counts based on status.
  • Set total as sum of all counts.
  • Determine health with simple rules, e.g.:
    • If proportion of draft or no-plan coverage for critical assets is high → 'critical'.
    • Else if there are some gaps or many drafts for critical assets → 'warning'.
    • Else → 'good'.

(For v1, you can use a simple ratio of active/total plans or a simple heuristic stub.)

6.2 Helper: computeCoverageStats(plans, assetList?)

Optional helper that:

  • Calculates how many assets at a site/area have:
    • At least one active plan.
    • No active plan.
  • Returns simple coverage metrics for dashboard display.

6.3 Controller Methods

dashboard(req, res, next)

  • Route: GET /albatross
  • Query active plans only by default ({ isActive: true }).
  • Compute global summary using summarizePlans.
  • Group plans by site (siteId / siteName):
    • Use Array .reduce or a Mongoose aggregate.
    • For each site, compute a site-level summary (counts + health class).
  • Map health to Tailwind classes, e.g.:
    • 'critical' → bg-red-500 text-white
    • 'warning' → bg-amber-400 text-black
    • 'good' → bg-green-500 text-white
  • Render albatross/dashboard with:
    {
                          title: 'Albatross Maintenance Plan Dashboard',
                          summary: { counts, total, health, cssClass },
                          sites: [
                            {
                              siteId,
                              siteName,
                              summary: { counts, total, health, cssClass }
                            },
                            ...
                          ]
                        }
                        

siteDetail(req, res, next)

  • Route: GET /albatross/site/:siteId
  • Filter plans by isActive: true and siteId.
  • Group by areaId / areaName and compute summaries.
  • Compute overall summary for the site.
  • Render albatross/site.

areaDetail(req, res, next)

  • Route: GET /albatross/site/:siteId/area/:areaId
  • Filter by siteId and areaId.
  • Group by equipmentId or list plans directly.
  • Render albatross/area.

equipmentDetail(req, res, next)

  • Route: GET /albatross/equipment/:equipmentId
  • Filter plans by equipmentId.
  • Show list of maintenance plans for that asset.
  • Render albatross/equipment.

listPlans(req, res, next)

  • Route: GET /albatross/plans
  • Support optional query filters:
    • siteId, areaId, equipmentId
    • status, planType, criticality
    • owner, tag
    • search (text search on title/description/planItems.taskDescription).
  • Return list and counts; display as a simple table.
  • Render albatross/plans/index.

newPlanForm(req, res)

  • Route: GET /albatross/plans/new
  • Optionally pre-populate asset fields if query params provided (?equipmentId=...).
  • Render albatross/plans/new with:
    • An empty plan header object.
    • One or two empty planItems rows to start with.

createPlan(req, res, next)

  • Route: POST /albatross/plans
  • Validate required fields: title, and at least one asset linkage (e.g. siteId or equipmentId).
  • Normalize empty strings to null for optional fields.
  • Parse tags from comma-separated string if provided.
  • Parse planItems from the request body (array of rows).
  • Discard empty item rows (no taskDescription and no componentName).
  • Call MaintenancePlan.create.
  • On success:
    • Redirect to /albatross/plans/:id or /albatross/plans.
  • On validation error:
    • Re-render new with error messages and entered data.

showPlan(req, res, next)

  • Route: GET /albatross/plans/:id
  • Fetch plan by id; check isActive if appropriate.
  • Compute any derived info (e.g. count of active items).
  • Map status, criticality, and planType to CSS badge classes.
  • Sort planItems by sortOrder and/or component name.
  • Render albatross/plans/show.

editPlanForm(req, res, next)

  • Route: GET /albatross/plans/:id/edit
  • Fetch the plan and pre-populate header and plan items.
  • Render albatross/plans/edit.

updatePlan(req, res, next)

  • Route: POST /albatross/plans/:id (or PUT with method override)
  • Fetch plan by id.
  • Update editable fields:
    • Header: title, description, planType, status, criticality, planCode, revision, etc.
    • Asset linkage: siteId, areaId, equipmentId (+ names if denormalized).
    • owner, tags, notes.
    • planItems: add, update, remove via array mapping:
      • Update existing item rows by _id.
      • Add new items where no _id but valid data present.
      • Mark items inactive or remove where flagged for deletion.
  • Save and redirect to show or list page.
  • On validation error: re-render edit.

deletePlan(req, res, next)

  • Route: POST /albatross/plans/:id/delete
  • Soft delete:
    • plan.isActive = false and/or plan.status = 'archived'.
    • plan.save().
  • Redirect to list page and optionally show a flash message.

activatePlan(req, res, next) (Optional)

  • Route: POST /albatross/plans/:id/activate
  • Set status = 'active' if validation passes.
  • Save and redirect back to the plan detail.

7. Views & Tailwind Layout

All views are located under: plugins/albatross/views/albatross/...

  • Use Tailwind CSS classes only.
  • Extend Shiftbulk main layout.

7.1 Dashboard View

File: plugins/albatross/views/albatross/dashboard.handlebars

Sections:

  1. Header – Title “Albatross Maintenance Plan Dashboard” + short subtitle.
  2. Global Summary Card – Status counts (draft, active, superseded, archived) and health indicator pill.
  3. Site / Area Grid – For each site:
    • Site name
    • Summary badges (active plans count, gap count, etc.)
    • Health indicator badge.
    • Link to site detail.
  4. Quick Actions:
    • “View All Maintenance Plans” → /albatross/plans
    • “New Maintenance Plan” → /albatross/plans/new

7.2 Site View

File: plugins/albatross/views/albatross/site.handlebars

  • Breadcrumb: Albatross > {{siteName}}
  • Summary card for this site (counts & health).
  • Table or grid grouping by areaName with plan counts and statuses.
  • Links to /albatross/site/{{siteId}}/area/{{areaId}}.

7.3 Area View

File: plugins/albatross/views/albatross/area.handlebars

  • Breadcrumb: Albatross > {{siteName}} > {{areaName}}
  • Summary for this area.
  • Table listing equipment and associated maintenance plans:
    • Asset name
    • Number of active plans
    • Status/highest criticality.
  • Links to /albatross/equipment/{{equipmentId}}.

7.4 Equipment View

File: plugins/albatross/views/albatross/equipment.handlebars

  • Breadcrumb: Albatross > {{siteName}} > {{areaName}} > {{equipmentName}}
  • Summary card plus list of maintenance plans for the asset.
  • Each plan card/row:
    • Title, planType, status, criticality
    • Link to plan detail page.

7.5 Maintenance Plans List View

File: plugins/albatross/views/albatross/plans/index.handlebars

  • Filter bar (compact Tailwind form UI):
    • Site, Area, Equipment (selects / autocompletes, integrating with Atlas).
    • Status select (draft, active, superseded, archived).
    • PlanType select.
    • Criticality select.
    • Search text input (title/description/component task).
  • Table columns:
    • Title
    • Site
    • Area
    • Equipment / Asset
    • Status badge
    • Criticality badge
    • PlanType badge
    • Owner
    • Number of active plan items
    • Actions (view / edit / delete / activate)

7.6 Maintenance Plan New / Edit Views

Files:

  • plugins/albatross/views/albatross/plans/new.handlebars
  • plugins/albatross/views/albatross/plans/edit.handlebars

Form sections:

Plan Header:

  • Title (text input)
  • Description (textarea)
  • Site / Area / Equipment selectors
  • PlanType select
  • Status select (Draft, Active, Superseded, Archived – status changes limited as needed)
  • Criticality select (Low, Medium, High, Critical)
  • PlanCode, Revision, RevisionDate, ApprovedBy
  • Owner, Tags, Notes

Plan Items (component-level grid/table):

  • Repeating rows with:
    • ComponentCode, ComponentName
    • TaskDescription
    • TaskType select
    • Frequency select
    • CustomIntervalDays (shown when frequency = Custom)
    • EstimatedDurationHours
    • SkillOrRole
    • ReferenceDocs (comma-separated string or array UI)
    • SafetyNotes
    • IsMandatory (checkbox)
    • IsActive (checkbox)
  • Add/Remove row controls via simple JS (optional in v1, can also be “static rows” with some capacity).

Use Tailwind form styles similar to falcon/finding_edit.

7.7 Maintenance Plan Show View

File: plugins/albatross/views/albatross/plans/show.handlebars

  • Display plan header in a panel:
    • Title + status & criticality badges
    • PlanType badge
    • Asset hierarchy: Site / Area / Equipment
    • PlanCode, Revision, RevisionDate, ApprovedBy
    • Owner, Tags, Notes
    • Description
  • Plan Items section:
    • Table or cards listing each plan item with:
      • Component (code + name)
      • TaskDescription
      • TaskType
      • Frequency (with custom interval if applicable)
      • EstimatedDurationHours
      • SkillOrRole
      • ReferenceDocs
      • SafetyNotes
      • Mandatory/Active indicators
  • Buttons:
    • “Edit Plan”
    • “Activate Plan” (if status = draft)
    • “Back to list”

8. Integration Points

8.1 Views Root

In the main app’s app.set('views', [...]), append:

path.join(__dirname, 'plugins/albatross/views')
                    

8.2 Partials

If Albatross defines partials (e.g. status/criticality badges):

  • Directory: plugins/albatross/views/albatross/partials
  • Add to partialsDir array in main app:
    {
                          dir: path.join(__dirname, 'plugins', 'albatross', 'views', 'albatross', 'partials'),
                          namespace: 'albatross'
                        }
                        
  • Optionally call the app’s helper to register the directory as a namespace.

8.3 Atlas Integration

  • Use Atlas models (AtlasSite, AtlasArea, AtlasEquipment) as references in the MaintenancePlan model.
  • Controllers may query Atlas to populate dropdowns for site/area/equipment selection.
  • Denormalized names (siteName, etc.) help render tables without extra joins.

8.4 Tailwind

  • Albatross views rely on Tailwind being included in the main layout.
  • No additional CSS or JS is strictly required in v1 (optional lightweight JS for dynamic plan item rows and cascaded dropdowns).

9. Validation & Error Handling

9.1 Server-Side Validation

  • title must be non-empty.
  • status, planType, criticality must be one of the allowed values.
  • At least one asset link (e.g. siteId or equipmentId) must be provided.
  • For each included plan item:
    • taskDescription must be non-empty.
    • frequency must be one of the allowed values.
    • If frequency === 'custom', then customIntervalDays must be a positive integer.
  • If required, enforce that at least one active plan item exists per plan.

9.2 On Validation Failure

  • Re-render the same form with error messages (simple <div> text is sufficient).
  • Preserve user’s entered values where possible.

9.3 404 Handling

  • If a plan is not found, use the main app’s 404 handler or redirect to /albatross/plans.

10. LLM Implementation Instructions (Meta)

10.1 Overall

  • Use CommonJS (require, module.exports).
  • Add "use strict"; at the top of each JS file.
  • Do not output diffs; output complete file contents.
  • Structure all code under plugins/albatross.

10.2 File Structure

plugins/
                      albatross/
                        index.js                          // Express router
                        models/
                          MaintenancePlan.js              // Mongoose model
                        controllers/
                          albatrossController.js          // All controller logic
                        views/
                          albatross/
                            dashboard.handlebars
                            site.handlebars
                            area.handlebars
                            equipment.handlebars
                            plans/
                              index.handlebars
                              new.handlebars
                              edit.handlebars
                              show.handlebars
                            partials/                     // optional, e.g. status/criticality badges
                              status_badge.handlebars
                              criticality_badge.handlebars
                              plantype_badge.handlebars
                    

10.3 index.js Requirements

  • Create an Express router.
  • Apply bodyParser middleware.
  • Set res.locals.basePath for all requests.
  • Wire up controller methods for all routes described in Section 5.
  • Export the router.

10.4 Controller Requirements

  • Implement all methods listed in Section 6.
  • Use the MaintenancePlan model for DB operations.
  • Centralize aggregation and status summarisation in helper function(s).
  • Compute CSS class strings in the controller and pass them to views (e.g. plan.statusClass, plan.criticalityClass, site.healthClass).

10.5 Model Requirements

  • Implement the schema exactly as described in Section 4.
  • Use timestamps: true.
  • Export Mongoose model as:
    module.exports = mongoose.model('MaintenancePlan', MaintenancePlanSchema);
                        

10.6 View Requirements

  • All views must:
    • Extend the 'main' layout.
    • Use Tailwind classes only (no Bootstrap).
    • Follow visual patterns from falcon/finding_edit (spacing, cards, headings).

10.7 Packaging as Downloadable Files

  • Bundle everything under plugins/albatross into a zip archive (e.g. albatross-plugin.zip).
  • Provide a link or reference for the user to download the zip (depending on execution environment).
  • Preserve directory structure exactly inside the archive.

If you’d like, next step I can turn this spec into actual files for plugins/albatross (model, controller, router, and stub views) so you can drop it directly into Shiftbulk.

modal1
modal2
modal3
docs_javascript
new_issue_button.handlebars
shortcut_edit