# dspsforms/dspsadvisingflow architecture

> Architecture diagram of the GitHub repository dspsforms/dspsadvisingflow, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dspsforms/dspsadvisingflow
- Repository: https://github.com/dspsforms/dspsadvisingflow

## Overview

1. **Repository shape**
   - This is a three-part system: `dspsmisc-backend`, `dspsmisc-ionic`, and `dspsmisc-print`.
   - The backend exposes the data and workflow APIs; the Ionic app is the main operational UI for staff/students; the print app is a separate Angular client optimized for printable form views and document-style rendering.

2. **Backend as the system hub**
   - `dspsmisc-backend` is the server-side application, organized into `routes`, `controllers`, `models`, `middleware`, and `config`.
   - The route/controller layer handles form management, user management, search, signatures, and “own form” flows.
   - The presence of many `models` plus `modelsOld` strongly suggests a document-database-style persistence layer with schema evolution and legacy compatibility.

3. **Main domain objects**
   - The core business objects are accommodation/intake forms and related student/user records.
   - Form families are explicit in both backend and clients: `aap1`, `aap2`, `aap2child`, `bluesheet`, and `greensheet`.
   - Shared schemas such as `common-form-schema`, `signature-model`, `student-model`, `user-model`, `random-key.model`, and `version-details-schema` indicate the system tracks lifecycle, signatures, and audit/version history.

4. **Workflow-oriented UI split**
   - `dspsmisc-ionic` is the primary application used by DSPS staff and other roles to create, edit, view, and search forms.
   - Its structure is route/page-based, with major areas for authentication, DSPS staff operations, instructor workflows, student tabs, landing pages, and print view.
   - The form UI is heavily componentized, with dedicated subcomponents for each section of each form type rather than a single generic form screen.

5. **Staff form processing pipeline**
   - The staff side centers on `dsps-staff/form`, which includes create/edit/list/view/search flows plus validation and transformation services.
   - `forms.service`, `data-transform.service`, and `form-validators` act as the client-side orchestration layer between form components and backend APIs.
   - The architecture supports multi-step forms, pagination, conditional sections, and signatures via reusable components like `sig-create`, `sig-view`, `elem-with-sig`, and `joint-sig-view`.

6. **Student-facing workflows**
   - The Ionic app also contains student-oriented flows: signup, email verification, login, password reset, and a student tabs area.
   - The README notes a separate student information submission application exists elsewhere; in this repo, the Ionic app still includes student interaction points for login and review/view operations.
   - Components such as `student-signup`, `validate-signup`, `reset-password-*`, and `single-sign-on` show that identity onboarding is part of the same system boundary.

7. **Authentication and authorization boundary**
   - Role-based access is enforced in both client and server.
   - Backend middleware includes checks for logged-in users and role gates such as admin, DSPS, faculty, instructor, staff, and student.
   - The clients mirror this with Angular route guards, so navigation and API access are both constrained by role.

8. **Messaging, email, and verification**
   - The backend has dedicated middleware for email notifications and password reset/verification flows, plus an email server/transport creator.
   - There is also captcha verification middleware and random-key status updates, which suggests self-service actions are protected by one-time tokens and anti-abuse checks.
   - These are not side features; they are part of the identity and form-signature lifecycle.

9. **Search and lookup as first-class operations**
   - Search is a distinct subsystem in both backend and client, with `search-controller`, `search-routes`, and staff search pages/components.
   - The system supports querying forms and student records, which is important for audit, follow-up, and historical workflow retrieval.

10. **Signature and legal recordkeeping**
   - Signature handling is a major architectural concern, not a UI embellishment.
   - Backend `signature-controller` and frontend signature components indicate signatures are persisted, displayed, and probably tied to specific form states.
   - The README explicitly frames the product as legal/audit-oriented, so immutable history and signed artifacts are part of the core data model.

11. **Print subsystem as a separate client**
   - `dspsmisc-print` is a second Angular application, distinct from the Ionic app, focused on presentation/printing rather than data entry.
   - It reuses the same domain concepts and many of the same form components, but adds print-specific UI pieces such as `print-view`, `view-form`, `generic`, and print-oriented assets/styles.
   - It also includes `sub-site-communicator`, which suggests cross-window or cross-site coordination with the main application.

12. **Shared domain duplication across clients**
   - The Ionic and print apps both contain similar model files and many parallel form components.
   - This indicates the architecture favors duplicated client implementations over a shared library, likely to allow differing UX requirements while preserving the same form semantics.

13. **Operational and deployment concerns**
   - The repository includes `dbBackup.sh`, production server templates, build scripts, and environment templates, so deployment is handled outside the app code but is clearly part of the architecture.
   - The `print` app also bundles third-party assets like Chart.js and Bootstrap, showing that rendering fidelity and document-style output matter operationally.

14. **High-level data flow**
   - Users authenticate in a client, which calls the backend API.
   - The backend authorizes the user, loads/stores student and form documents, records signatures and history, and sends email notifications where needed.
   - The Ionic app is the main transactional client; the print app is used to render finalized or printable views of the same underlying records.

15. **Architecture diagram guidance**
   - A useful diagram would show three deployable applications around one shared backend.
   - Inside the backend, draw separate lanes for authentication, form CRUD, search, signatures, notifications, and persistence/models.
   - On the client side, distinguish the main workflow UI from the print-only UI, and show shared domain concepts flowing between both and the backend.

Main entry points: [`dspsmisc-backend/routes`](https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-backend/routes) (API routes), [`dspsmisc-backend/controllers/user-controller.js`](https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-backend/controllers/user-controller.js) (User ctrl), [`dspsmisc-print/src/app/print-view`](https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-print/src/app/print-view) (View routes), [`dspsmisc-backend/models`](https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-backend/models) (Form models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_backend["Backend"]
  node_backend_server(("Server<br/>Node app<br/>[server.js]"))
  node_backend_api["API routes<br/>Express routes"]
  node_backend_ctrl_forms["Form ctrl<br/>Domain controllers<br/>[form-controller.js]"]
  node_backend_ctrl_users["User ctrl<br/>User controllers<br/>[user-controller.js]"]
  node_backend_ctrl_search["Search ctrl<br/>Search controller"]
  node_backend_ctrl_sign["Signature ctrl<br/>Signature controller"]
  node_backend_mw_auth["Auth gates<br/>Middleware"]
  node_backend_mw_notify["Notify flow<br/>Email middleware"]
  node_backend_mw_security["Security flow<br/>Middleware"]
  node_backend_models_forms[("Form models<br/>Document models")]
  node_backend_models_people[("People models<br/>User/student models<br/>[student-model.js]")]
  node_backend_models_audit[("Audit models<br/>History/version schemas")]
end

subgraph group_ionic["Ionic App"]
  node_ionic_app(("Ionic app<br/>Angular/Ionic client"))
  node_ionic_auth["Auth area<br/>Identity flows"]
  node_ionic_staff["Staff ops<br/>Workflow UI"]
  node_ionic_formsvc["Form services<br/>Client orchestration<br/>[forms.service.ts]"]
  node_ionic_forms["Form UI<br/>Form components"]
  node_ionic_students["Student tabs<br/>Student workflows"]
  node_ionic_printview["Print view<br/>Presentation route"]
end

subgraph group_print["Print App"]
  node_print_app(("Print app<br/>Angular print client"))
  node_print_bridge["Site bridge<br/>Communicator"]
  node_print_view["View routes<br/>Print routes"]
  node_print_forms["Print forms<br/>Print components"]
end

node_backend_server -->|"serves"| node_backend_api
node_backend_api -->|"dispatches"| node_backend_ctrl_forms
node_backend_api -->|"dispatches"| node_backend_ctrl_users
node_backend_api -->|"dispatches"| node_backend_ctrl_search
node_backend_api -->|"dispatches"| node_backend_ctrl_sign
node_backend_ctrl_forms -->|"reads/writes"| node_backend_models_forms
node_backend_ctrl_users -->|"reads/writes"| node_backend_models_people
node_backend_ctrl_sign -->|"persists"| node_backend_models_audit
node_backend_ctrl_search -->|"queries"| node_backend_models_people
node_backend_ctrl_search -->|"queries"| node_backend_models_forms
node_backend_mw_auth -->|"protects"| node_backend_api
node_backend_mw_notify -->|"supports"| node_backend_ctrl_users
node_backend_mw_security -->|"protects"| node_backend_ctrl_sign
node_ionic_app -->|"routes to"| node_ionic_auth
node_ionic_app -->|"routes to"| node_ionic_staff
node_ionic_staff -->|"uses"| node_ionic_formsvc
node_ionic_formsvc -->|"calls"| node_backend_api
node_ionic_staff -->|"renders"| node_ionic_forms
node_ionic_forms -.->|"matches"| node_backend_models_forms
node_ionic_auth -->|"authenticates"| node_backend_ctrl_users
node_ionic_students -->|"reads"| node_backend_ctrl_users
node_ionic_printview -.->|"hands off"| node_print_view
node_print_app -->|"coordinates"| node_print_bridge
node_print_app -->|"routes to"| node_print_view
node_print_view -->|"composes"| node_print_forms
node_print_forms -.->|"matches"| node_backend_models_forms
node_print_view -->|"reads via API"| node_backend_api
node_ionic_forms -.->|"shared domain"| node_print_forms

click node_backend_server "https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-backend/server.js"
click node_backend_api "https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-backend/routes"
click node_backend_ctrl_forms "https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-backend/controllers/form-controller.js"
click node_backend_ctrl_users "https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-backend/controllers/user-controller.js"
click node_backend_ctrl_search "https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-backend/controllers/search-controller.js"
click node_backend_ctrl_sign "https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-backend/controllers/signature-controller.js"
click node_backend_mw_auth "https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-backend/middleware"
click node_backend_mw_notify "https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-backend/middleware/email-notify-dsps.js"
click node_backend_mw_security "https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-backend/middleware/verify-captchav3.js"
click node_backend_models_forms "https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-backend/models"
click node_backend_models_people "https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-backend/models/student-model.js"
click node_backend_models_audit "https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-backend/models/version-details-schema.js"
click node_ionic_app "https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-ionic/src/app/app-routing.module.ts"
click node_ionic_auth "https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-ionic/src/app/auth"
click node_ionic_staff "https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-ionic/src/app/dsps-staff"
click node_ionic_formsvc "https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-ionic/src/app/dsps-staff/form/forms.service.ts"
click node_ionic_forms "https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-ionic/src/app/dsps-staff/form/component"
click node_ionic_students "https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-ionic/src/app/student-tabs"
click node_ionic_printview "https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-ionic/src/app/print-view"
click node_print_app "https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-print/src/app/app-routing.module.ts"
click node_print_bridge "https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-print/src/app/auth/sub-site-communicator"
click node_print_view "https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-print/src/app/print-view"
click node_print_forms "https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-print/src/app/dsps-staff/form/component"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_backend_server,node_backend_api,node_backend_ctrl_forms,node_backend_ctrl_users,node_backend_ctrl_search,node_backend_ctrl_sign,node_backend_mw_auth,node_backend_mw_notify,node_backend_mw_security,node_backend_models_forms,node_backend_models_people,node_backend_models_audit toneBlue
class node_ionic_app,node_ionic_auth,node_ionic_staff,node_ionic_formsvc,node_ionic_forms,node_ionic_students,node_ionic_printview toneAmber
class node_print_app,node_print_bridge,node_print_view,node_print_forms toneMint
```

## Components

### Backend

API server, middleware, routes, and persistence models.

- [Server](https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-backend/server.js): Node app · Main backend entrypoint and deployment process. · `dspsmisc-backend/server.js`
- [API routes](https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-backend/routes): Express routes · Form, user, search, own-form, and signature endpoints. · `dspsmisc-backend/routes`
- [Form ctrl](https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-backend/controllers/form-controller.js): Domain controllers · Form lifecycle, common-form, and own-form workflows. · `dspsmisc-backend/controllers/form-controller.js`
- [User ctrl](https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-backend/controllers/user-controller.js): User controllers · User management and account-related operations. · `dspsmisc-backend/controllers/user-controller.js`
- [Search ctrl](https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-backend/controllers/search-controller.js): Search controller · Lookup and retrieval for forms and student records. · `dspsmisc-backend/controllers/search-controller.js`
- [Signature ctrl](https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-backend/controllers/signature-controller.js): Signature controller · Signature persistence and signed-record operations. · `dspsmisc-backend/controllers/signature-controller.js`
- [Auth gates](https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-backend/middleware): Middleware · Logged-in and role checks for admin, DSPS, faculty, instructor, staff, and student. · `dspsmisc-backend/middleware`
- [Notify flow](https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-backend/middleware/email-notify-dsps.js): Email middleware · Email verification, password reset, and DSPS/student notifications. · `dspsmisc-backend/middleware/email-notify-dsps.js`
- [Security flow](https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-backend/middleware/verify-captchav3.js): Middleware · Captcha verification, random-key status updates, and user identity extraction. · `dspsmisc-backend/middleware/verify-captchav3.js`
- [Form models](https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-backend/models): Document models · AAP1, AAP2, AAP2-child, Bluesheet, Greensheet, and shared form schemas. · `dspsmisc-backend/models`
- [People models](https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-backend/models/student-model.js): User/student models · Student, temporary student, user, and feedback records. · `dspsmisc-backend/models/student-model.js`
- [Audit models](https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-backend/models/version-details-schema.js): History/version schemas · Version details, meta history, signatures, and random keys. · `dspsmisc-backend/models/version-details-schema.js`

### Ionic App

Primary operational client for staff and student workflows.

- [Ionic app](https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-ionic/src/app/app-routing.module.ts): Angular/Ionic client · Primary operational UI for staff and students. · `dspsmisc-ionic/src/app/app-routing.module.ts`
- [Auth area](https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-ionic/src/app/auth): Identity flows · Login, signup, email validation, reset password, SSO, and role guards. · `dspsmisc-ionic/src/app/auth`
- [Staff ops](https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-ionic/src/app/dsps-staff): Workflow UI · Staff landing area for form creation, editing, listing, view, and search. · `dspsmisc-ionic/src/app/dsps-staff`
- [Form services](https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-ionic/src/app/dsps-staff/form/forms.service.ts): Client orchestration · Form API service, validators, transforms, and operation status tracking. · `dspsmisc-ionic/src/app/dsps-staff/form/forms.service.ts`
- [Form UI](https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-ionic/src/app/dsps-staff/form/component): Form components · Componentized AAP1, AAP2, Bluesheet, and Greensheet editors and viewers. · `dspsmisc-ionic/src/app/dsps-staff/form/component`
- [Student tabs](https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-ionic/src/app/student-tabs): Student workflows · Student list and student view-form area inside the client boundary. · `dspsmisc-ionic/src/app/student-tabs`
- [Print view](https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-ionic/src/app/print-view): Presentation route · Client-side printable view entry point used from the main app. · `dspsmisc-ionic/src/app/print-view`

### Print App

Angular client specialized for printable form views.

- [Print app](https://github.com/dspsforms/dspsadvisingflow/blob/master/dspsmisc-print/src/app/app-routing.module.ts): Angular print client · Separate Angular application for printable and document-style rendering. · `dspsmisc-print/src/app/app-routing.module.ts`
- [Site bridge](https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-print/src/app/auth/sub-site-communicator): Communicator · Cross-window/sub-site coordination used by the print client. · `dspsmisc-print/src/app/auth/sub-site-communicator`
- [View routes](https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-print/src/app/print-view): Print routes · Print-view and view-form pages for final rendered records. · `dspsmisc-print/src/app/print-view`
- [Print forms](https://github.com/dspsforms/dspsadvisingflow/tree/master/dspsmisc-print/src/app/dsps-staff/form/component): Print components · Printable AAP, Bluesheet, Greensheet, signature, and label/value components. · `dspsmisc-print/src/app/dsps-staff/form/component`

## Connections

- Server → API routes: serves · Server exposes the route layer.
- API routes → Form ctrl: dispatches · Routes delegate form lifecycle actions to controllers.
- API routes → User ctrl: dispatches · Routes delegate account operations.
- API routes → Search ctrl: dispatches · Routes delegate lookup requests.
- API routes → Signature ctrl: dispatches · Routes delegate signature actions.
- Form ctrl → Form models: reads/writes · Form controllers persist domain documents.
- User ctrl → People models: reads/writes · User controllers manage people records.
- Signature ctrl → Audit models: persists · Signatures and version history are recorded as audit data.
- Search ctrl → People models: queries · Search spans student and user records.
- Search ctrl → Form models: queries · Search spans stored forms.
- Auth gates → API routes: protects · Role gates wrap backend endpoints.
- Notify flow → User ctrl: supports · Verification and reset flows support account actions.
- Security flow → Signature ctrl: protects · Token and captcha checks support sensitive flows.
- Ionic app → Auth area: routes to · Client entry includes identity and role flows.
- Ionic app → Staff ops: routes to · Primary operational navigation lands in staff workflows.
- Staff ops → Form services: uses · Staff pages orchestrate API and validation logic.
- Form services → API routes: calls · Client services talk to backend endpoints.
- Staff ops → Form UI: renders · Staff workflow pages mount form-specific components.
- Form UI → Form models: matches · Client form families mirror backend document shapes.
- Auth area → User ctrl: authenticates · Login, signup, reset, and verification reach user APIs.
- Student tabs → User ctrl: reads · Student tabs interact with student/account data.
- Print view → View routes: hands off · The main app offers a print-oriented route.
- Print app → Site bridge: coordinates · Print client communicates with its host site.
- Print app → View routes: routes to · Print app entry focuses on render-only pages.
- View routes → Print forms: composes · Printable pages assemble form-specific UI pieces.
- Print forms → Form models: matches · Print components reuse the same underlying form semantics.
- View routes → API routes: reads via API · Final printable records are loaded from the backend.
- Form UI → Print forms: shared domain · Both clients implement parallel domain-specific form UI.
