ARTICLE AD BOX
I’m building an HRIS in Spring Boot with MongoDB, and I need to generate an organization chart from an employees collection.
My current model is:
@Document(collection = "employees") public class Employee { @Id private String id; @Indexed private String organizationId; @Indexed private String userId; private String departmentId; private String supervisorId; private EmployeeStatus status; private String email; private String employeeCode; private String firstName; private String lastName; private String preferredName; private String designation; }The org chart is based on the reporting hierarchy using supervisorId.
I’m trying to decide the best approach for this kind of structure:
Should I build the tree in memory from a flat employee list?
Should I store additional hierarchy fields like ancestorIds or a materialized path?
Is MongoDB $graphLookup a good option here?
How do I keep this efficient when the chart gets large?
Should org structure be modeled around employees, positions, or both?
What is the recommended design pattern for this in a HRIS? I want this to be highly scalable and fast
