Skip to main content

Architecture: hbf-media-manager

C4 Component Diagram

Key Flows

Upload (POST /organization/:orgId/media)

  1. Request hits MediaController.createMedia.
  2. HBFGuard validates the bearer token against hbf-core; user object is injected into the request.
  3. MemberOrgRoleGuard checks the user has at least member role in the org.
  4. FileSizeValidationPipe enforces per-MIME-type max size (MAX_IMAGE_SIZE, MAX_VIDEO_SIZE, MAX_AUDIO_SIZE).
  5. MediaService.createMedia generates a random 7-char prefix, uploads the file to S3 via multipart upload (10 MB parts), saves metadata to MySQL, then emits an audit log to hbf-core.
  6. Returns the saved Media entity.

Delete (DELETE /organization/:orgId/media/:id)

  1. AdminOrgRoleGuard restricts to org admins.
  2. MediaService.deleteMedia looks up the record in MySQL, deletes the S3 object, removes the DB row, and emits an audit log.

List (GET /organization/:orgId/media)

  1. MemberOrgRoleGuard applies.
  2. MediaService.listMediaByOrg runs a TypeORM query builder with optional search, MIME type filter, createdBy filter, and pagination. Returns data, count, available fileTypes, and uploadedBy facets.