Skip to main content

2025-09-05

1. Project Definition Structure (MongoDB Collection: projects)

In MongoDB, this will be your projects collection. Each document in this collection represents a single project.

Proposed Project Model (Project.php)

Field Definition (projects collection)

Initial CRUD (Laravel/MongoDB Context)

  • Create: A standard Project::create($validatedData) call in your controller.
  • Read (List): Project::where('isArchived', false)->get() with filters applied via additional where() clauses.
  • Read (Detail): Project::findOrFail($id).
  • Update: $project->update($validatedData).
  • Delete (Soft): $project->update(['isArchived' => true]).

2. Organisation and Flow of Project Document Schedule & Tracking

With MongoDB, you have a choice: embed revisions within the parent document or keep them in a separate collection.
  • Embedding: Fast reads, but can lead to large documents (16MB limit) and makes querying across all revisions in the system difficult.
  • Separate Collection (Referencing): The recommended, more scalable approach. It mimics a relational structure but with the flexibility of NoSQL. It keeps document size manageable and allows for powerful queries on the revisions themselves.
Let’s proceed with the Separate Collection approach.

Model 1: ProjectDocument (Collection: projectDocuments)

This collection holds the master record for each controlled document. It contains metadata and, crucially, a summary of its current state for fast lookups. Example of currentRevision Embedded Document: This is the key for performance. When you load the document list, you don’t need a second query to find the status of every document.

Model 2: DocumentRevision (Collection: documentRevisions)

This collection is the auditable history—a log of every version of every document. Example of fileReference Embedded Document: This provides flexibility for different storage providers.

Flow and CRUD (Laravel/MongoDB Context)

  1. Create a New Document:
  • A user fills out a form for a new document (docCode, title, etc.) within a project.
  • Transactionally:
  1. Create the ProjectDocument record.
  2. Create the first DocumentRevision record (e.g., Rev A) with status: 'Draft'.
  3. Update the ProjectDocument’s currentRevision embedded document with the info from the new revision.
  4. Submit for Review (State Transition):
  • The author uploads a file and clicks “Submit”.
  • The backend updates the corresponding DocumentRevision record, changing status from Draft to Submitted for Review and setting actualSubmissionDate.
  • The ProjectDocument’s currentRevision.status is also updated to reflect this change.
  1. Approve/Reject (State Transition):
  • The reviewer makes a decision.
  • The backend updates the DocumentRevision record’s status to Approved or Resubmission Required.
  • The ProjectDocument’s currentRevision.status is updated.
  1. Create a New Revision:
  • A user initiates a new revision (e.g., because the previous was Resubmission Required or needs an update).
  • Transactionally:
  1. Find the old DocumentRevision and update its status to Superseded.
  2. Create a new DocumentRevision record (e.g., Rev B) with status: 'Draft'.
  3. Update the parent ProjectDocument’s currentRevision embedded document to point to this new Rev B.

Alternative Collection Views (How to Query)

The frontend views remain the same, but the backend queries will leverage this MongoDB structure.

1. Document Register View (List-Based)

  • Query: Simply ProjectDocument::where('projectId', $projectId)->get().
  • Why it’s fast: All the necessary data (docCode, title, currentRevision.status, currentRevision.revisionNumber) is in the main document. No joins or lookups are needed to display the list, making it highly performant.

2. Timeline View (Schedule-Based)

  • Query: DocumentRevision::whereIn('documentId', $documentIds)->get(). ($documentIds is an array of _ids from the project’s documents).
  • Logic: This query fetches all historical and current revisions for the documents in the project. You can then iterate through these in your backend or frontend to build the timeline, plotting bars based on plannedSubmissionDate and plannedApprovalDate. You can filter this query for only the “active” revisions if needed.

3. Kanban Board View (Workflow-Based)

  • Query: ProjectDocument::where('projectId', $projectId)->get().
  • Logic: The data for the Kanban board also comes directly from the projectDocuments collection. The frontend logic would group the documents into columns based on the value of the currentRevision.status field. Drag-and-drop actions would trigger API calls to perform the state transitions described in the workflow above.

Flow & Entity Diagram

Of course. Visualizing the flow and relationships is a crucial step. Here are the visualizations using Mermaid notation for both the document lifecycle flow and the data entity relationships.

1. Document Revision Workflow (The Flow)

This diagram illustrates the lifecycle of a single document revision. It shows the states a revision can be in and the actions that cause it to transition from one state to another. The key concept is that actions like “Approve” or “Reject” are terminal for a specific revision (e.g., Rev A). To continue work, a new revision (Rev B) is created, which starts the lifecycle over again from the Draft state.

2. Data Entity Relationship Diagram (The Structure)

This ER diagram shows how the different MongoDB collections (projects, projectDocuments, documentRevisions, etc.) are related to each other. It clarifies the “one-to-many” relationships that form the backbone of your system.
  • A Project contains many ProjectDocuments.
  • A ProjectDocument has a history of many DocumentRevisions.
  • Users play multiple roles (Project Manager, Author, Reviewer).

How to Interpret the ER Diagram:

  • ||--|{: Represents a “one-to-many” relationship. For example, one PROJECTS record is related to many PROJECT_DOCUMENTS records.
  • }o--|{: Also represents a “one-to-many” relationship, but drawn from the perspective of the “one” side. For example, one USERS record can be related to many PROJECTS as a manager.
  • PK: Stands for Primary Key (in MongoDB, this is the _id).
  • FK: Stands for Foreign Key. This indicates a field that stores the _id from another collection to create a relationship (e.g., PROJECT_DOCUMENTS.projectId stores a PROJECTS._id).

UI / UX

Excellent request. Visualizing the user interface (UI) flow and its connection to the backend CRUD operations is key to understanding how the system will function. Here are visualizations using Mermaid’s flowchart notation. I’ve broken it down into the two main areas as before: Project Management and Project Document Management.

1. Project Management CRUD Flow

This diagram illustrates the user journey for managing the Project Register. It’s a standard and straightforward CRUD implementation.

Explanation of the Project Flow:

  1. Collection View (Project Register):
  • The user starts at a list of all projects, presented in a Datatable. This is the main “Read” (List) screen.
  • From here, they can initiate creating a new project or select an existing one to view its details.
  1. Create Form UI (Create Project Form):
  • A simple form to input the project’s details (projectName, projectCode, etc.).
  • Submitting this form makes a POST request to your API. On success, the user is redirected back to the register, which now shows the new project.
  1. View Item UI (Project Dashboard):
  • This is the detailed view of a single project. It displays all the project’s information.
  • This page is the hub for actions related to this specific project, such as editing it, archiving it, or, most importantly, navigating to its associated documents.
  1. Edit Form UI (Edit Project Form):
  • Identical to the create form but is pre-populated with the existing project’s data.
  • Submitting makes a PUT or PATCH request to update the record.

2. Project Document Management CRUD Flow

This flow is more complex because it involves multiple view types and a workflow-driven update process (state changes).

Explanation of the Document Flow:

  1. Entry Point (Project Dashboard): The user is already looking at a specific project and chooses to manage its documents.
  2. Collection Views (The Core):
  • The user is presented with one or more ways to view the document register. A toggle or menu allows them to switch between views.
  • Datatable: The default, information-rich view.
  • Timeline: Visualizes the schedule.
  • Kanban: Visualizes the workflow status.
  • Grid: Best for visually-oriented documents like architectural drawings or mockups, showing thumbnails.
  • Tree Datatable: Ideal for complex document sets where documents are nested, like a master specification with multiple sub-sections.
  • All these views offer two primary actions: Add a new document or View an existing document’s details.
  1. Create Form UI (Create Document Form):
  • This form is for creating the master document record (ProjectDocument). It captures metadata like the docCode and title. The initial revision is typically created automatically in the background with a Draft status.
  1. View Item UI (Document Detail Page):
  • This is the hub for a single document. It shows all its metadata and, most importantly, a list of its revisions (Rev A, Rev B, etc.).
  • From here, the user can perform two distinct types of “updates”:
  • Edit Metadata: Changes the master document record (e.g., correcting a typo in the title).
  • Create New Revision: This is the main workflow action. It opens a form to upload a new file, creating a new DocumentRevision record and starting its lifecycle.
  1. Special Case - Kanban Update:
  • The Kanban view offers a unique, streamlined update process. Instead of opening a form, the user can simply drag a card from one column (e.g., Submitted for Review) to another (e.g., Approved).
  • This UI action triggers a direct PATCH request to the API to update only the status of that revision, providing a fast and intuitive user experience for managing workflow.

Wireframes ( Table Based )

Absolutely. Here is the combined output, pairing each UI wireframe (approximated in a Markdown table) with its detailed component breakdown. This provides both a visual layout and a functional explanation for each key screen.

1. Project Register (List/Datatable View)

UI Layout

Component Breakdown

Purpose: To display a list of all active projects, allowing users to search, filter, and navigate to a specific project or create a new one.

2. Create / Edit Project Form

UI Layout

Component Breakdown

Purpose: To provide a user interface for entering or modifying project details. The view is shared for both “Create” and “Edit” modes.

3. Project Dashboard (View Project Details)

UI Layout

Component Breakdown

Purpose: To serve as the central hub for a single project, displaying all its information and providing navigation to related modules like documents.

4. Document Register (List/Datatable View)

UI Layout

Component Breakdown

Purpose: Located within a project, this view lists all documents associated with it and allows users to switch between different visualization modes.

5. Document Detail Page (View Document Details)

UI Layout

Component Breakdown

Purpose: To display the complete information and version history for a single document.

6. Create New Revision Form

UI Layout

Component Breakdown

Purpose: A focused form for uploading a new version of an existing document and setting its schedule.

Wireframes ( Text Based )

Okay, here are basic wireframes for the key CRUD views we’ve discussed, focusing on layout and core elements. These wireframes are simple sketches, not fully designed UIs. They’re meant to illustrate the structure and interaction flow.

1. Project Register (List/Datatable View)

Key Elements:
  • “New Project” Button: Initiates the Create operation.
  • Search & Filters: Allow users to quickly find projects.
  • Datatable: Columns display key project information. Clicking on a row navigates to the Project Dashboard.
  • Pagination: Handles large numbers of projects.

2. Create/Edit Project Form

Key Elements:
  • Title: Indicates whether it’s a Create or Edit form.
  • “Back” Button: Returns to the Project Register or Dashboard.
  • Form Fields: Capture all project data.
  • Required Indicators: Clearly marks mandatory fields.
  • “Cancel” & “Save” Buttons: Actions for the form. Project Code should be disabled in edit mode.

3. Project Dashboard (View Project Details)

Key Elements:
  • Title: Shows the Project Name.
  • “Back” Button: Returns to the Project Register.
  • Action Buttons: “Edit” and “Archive”.
  • Display Fields: Presents all project data in a read-only format.
  • Tab Navigation: Organizes related information (documents, team members, risks, issues, etc.). The “Documents” tab leads to the Document Management views.

4. Document Register (List/Datatable View)

This view is within the Project Dashboard, under the “Documents” tab.
Key Elements:
  • “Back” Button: Returns to the Project Dashboard.
  • ”+ Add Document” Button: Creates a new ProjectDocument record.
  • “View” Dropdown: Selects between Datatable, Timeline, Kanban, Grid, Tree Table views.
  • Filters: Specific to document attributes (Discipline, Status).
  • Datatable: Displays document metadata. Clicking a row leads to the Document Detail Page.

5. Document Detail Page (View Document Details)

Key Elements:
  • “Back” Button: Returns to the Document List.
  • “Edit Metadata” Button: Allows editing of the core document record.
  • “Create New Revision” Button: Initiates the upload of a new file and the creation of a new DocumentRevision.
  • Document Metadata: Displays the document’s main attributes.
  • Revisions Table: Shows the history of revisions for the document, including their status, author, dates, and the download link for the file.
  • The “Actions” column might include a “View” action to see more details about a specific revision, though that’s often not needed given the information already present.

6. Create New Revision Form

Key Elements:
  • Clear Label : Indicates the form for creating new revision
  • Important Input : Date Pickers to specify the schedule
  • Important Input : File Upload field to put latest document version.
These wireframes are starting points. The specifics of your UI will depend on your design choices, target users, and the overall look and feel you want to achieve.