# suhasj1231/workhub architecture

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

- Interactive diagram: https://gitdiagram.com/suhasj1231/workhub
- Repository: https://github.com/suhasj1231/workhub

## Overview

1. **Overall shape**
   WorkHub is a single Spring Boot backend application, built with Java 21 and Gradle, and persisted in PostgreSQL. It is a **modular monolith**: one deployable service with clear feature modules under `com.smj.workhub.*`, rather than separate microservices.

2. **Core business hierarchy**
   The central domain model is the hierarchy **Workspace → Project → Task**. Workspaces contain projects, and projects contain tasks. This hierarchy drives most API routes, persistence relationships, filtering, and authorization checks.

3. **HTTP/API boundary**
   Each feature area has its own controller package: `workspace`, `project`, `task`, `auth`, `comment`, `notification`, `attachment`, `activity`, and messaging/websocket endpoints. Controllers expose DTO-based REST APIs and are the primary ingress point for external clients.

4. **Layered request flow**
   The dominant flow is: **Controller → Service → Repository → Entity/DB**. Controllers validate and translate requests, services enforce business rules and orchestration, and repositories use Spring Data JPA to read/write entities. DTOs isolate API contracts from persistence entities.

5. **Persistence model and querying**
   Each major domain has an entity/repository pair: `Workspace`, `Project`, `Task`, `User`, `Comment`, `Notification`, `Attachment`, `ActivityLog`, plus supporting membership/event entities. Specification classes for workspace/project/task/activity support **dynamic filtering** and pagination-style queries, which is a notable architectural concern in the data access layer.

6. **Soft-delete and lifecycle handling**
   The system uses soft deletes across key entities, with restore endpoints for workspaces and projects and likely similar lifecycle management elsewhere. This means “delete” is usually a state transition in the database, not a hard removal, and repositories/specifications must consistently exclude deleted records.

7. **Authorization and access control**
   Security is JWT-based. A `JwtAuthenticationFilter`, `JwtService`, and `UserPrincipal`/`UserPrincipalService` handle authentication, while workspace access is enforced through dedicated access services. This suggests a two-step boundary: authenticate the user first, then authorize actions based on workspace membership/role.

8. **User and auth subsystem**
   Authentication is separated into `auth` and `user` modules. `AuthService` handles register/login flows, DTOs model credential and response shapes, and `EmailService` indicates email-based side effects such as verification or notifications. User roles/status/provider enums show that identity is managed explicitly, not embedded in the auth layer.

9. **Collaboration and activity features**
   Comments, activities, attachments, and notifications are separate subsystems around the core work hierarchy. Comments emit a `CommentCreatedEvent`, activities record user actions, attachments track file metadata, and notifications provide user-facing event summaries. These features are likely connected more through domain events than direct synchronous calls.

10. **Event-driven and async processing**
   The presence of Kafka producer/consumer services, consumer config, `AsyncConfig`, `ProcessedEvent`, and multiple event listeners indicates an **asynchronous event pipeline**. Domain events can be published, consumed, deduplicated, and converted into notifications or websocket pushes without blocking the main request path.

11. **Real-time delivery path**
   WebSocket support is a separate messaging channel for live updates. The websocket config, event listener, and notification service imply that some backend events are fanned out to connected clients in real time, alongside the REST API and possibly in parallel with Kafka-driven processing.

12. **Operational support boundaries**
   Cross-cutting infrastructure is centralized in `common` and `config`: global exception handling, structured API error responses, request logging, OpenAPI docs, Redis configuration, and caching support. These are application-wide concerns rather than feature-specific logic, and they help define the runtime behavior of the whole backend.

13. **Cache and infrastructure integrations**
   `RedisCacheService` and `RedisConfig` show Redis is part of the architecture, likely for caching or transient state. Combined with Kafka and WebSockets, the app integrates multiple infrastructure components: PostgreSQL as system of record, Redis for fast access/state, Kafka for async messaging, and WebSockets for push updates.

14. **What to show in an architecture diagram**
   The clearest diagram would center on the **REST API layer**, the **domain service layer**, the **JPA repository/persistence layer**, and the **event/messaging side channels**. Then draw the main domain chain (Workspace → Project → Task), with auxiliary modules branching off it: auth/security, comments/activities, notifications, attachments, and websocket/kafka/redis infrastructure.

Main entry points: [`src/main/java/com/smj/workhub/WorkhubApplication.java`](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/WorkhubApplication.java) (Workhub), [`src/main/java/com/smj/workhub/workspace/service/impl/WorkspaceServiceImpl.java`](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/workspace/service/impl/WorkspaceServiceImpl.java) (Workspace Service), [`src/main/java/com/smj/workhub/project/service/impl/ProjectServiceImpl.java`](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/project/service/impl/ProjectServiceImpl.java) (Project Service), [`src/main/java/com/smj/workhub/task/service/impl/TaskServiceImpl.java`](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/task/service/impl/TaskServiceImpl.java) (Task Service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_workhub_app(("Workhub<br/>Spring Boot app"))
end

subgraph group_api["HTTP API"]
  node_workspace_controller["Workspace API<br/>REST controller"]
  node_project_controller["Project API<br/>REST controller"]
  node_task_controller["Task API<br/>REST controller"]
  node_comment_controller["Comment API<br/>REST controller"]
  node_auth_controller["Auth API<br/>REST controller"]
end

subgraph group_domain["Core Domain"]
  node_workspace_service["Workspace Service<br/>domain service"]
  node_workspace_access["Access Control<br/>authorization service"]
  node_project_service["Project Service<br/>domain service"]
  node_task_service["Task Service<br/>domain service"]
  node_comment_service["Comment Service<br/>domain service"]
  node_notification_service["Notification Service"]
  node_activity_service["Activity Service<br/>audit service"]
  node_attachment_service["Attachment Service<br/>file service"]
  node_auth_service["Auth Service<br/>identity service"]
end

subgraph group_infra["Infrastructure"]
  node_user_store[("User Model<br/>user entity/repository<br/>[User.java]")]
  node_workspace_store[("Workspace Store<br/>workspace entity/repository<br/>[Workspace.java]")]
  node_project_store[("Project Store<br/>project entity/repository<br/>[Project.java]")]
  node_task_store[("Task Store<br/>task entity/repository<br/>[Task.java]")]
  node_collab_store[("Collab Store<br/>comment/activity/attachment/notification persistence")]
  node_security_stack["JWT Security<br/>security filter/service"]
  node_event_pipeline["Event Pipeline<br/>async messaging"]
  node_websocket_channel["WebSocket Channel<br/>real-time delivery"]
  node_common_ops["Common Ops<br/>cross-cutting"]
end

node_workhub_app -->|"hosts"| node_workspace_controller
node_workhub_app -->|"hosts"| node_project_controller
node_workhub_app -->|"hosts"| node_task_controller
node_workhub_app -->|"hosts"| node_comment_controller
node_workhub_app -->|"hosts"| node_auth_controller
node_workspace_controller -->|"calls"| node_workspace_service
node_project_controller -->|"calls"| node_project_service
node_task_controller -->|"calls"| node_task_service
node_comment_controller -->|"calls"| node_comment_service
node_auth_controller -->|"calls"| node_auth_service
node_workspace_service -->|"persists"| node_workspace_store
node_workspace_service -->|"authorizes"| node_workspace_access
node_project_service -->|"persists"| node_project_store
node_task_service -->|"persists"| node_task_store
node_comment_service -->|"persists"| node_collab_store
node_activity_service -->|"persists"| node_collab_store
node_attachment_service -->|"persists"| node_collab_store
node_notification_service -->|"persists"| node_collab_store
node_auth_service -->|"uses"| node_user_store
node_security_stack -->|"protects"| node_auth_controller
node_security_stack -->|"guards"| node_workspace_access
node_comment_service -->|"publishes"| node_event_pipeline
node_event_pipeline -->|"consumes"| node_notification_service
node_event_pipeline -->|"fans out"| node_websocket_channel
node_notification_service -->|"pushes"| node_websocket_channel
node_workspace_service -->|"relies on"| node_common_ops
node_project_service -->|"relies on"| node_common_ops
node_task_service -->|"relies on"| node_common_ops

click node_workhub_app "https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/WorkhubApplication.java"
click node_workspace_controller "https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/workspace/controller/WorkspaceController.java"
click node_project_controller "https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/project/controller/ProjectController.java"
click node_task_controller "https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/task/controller/TaskController.java"
click node_comment_controller "https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/comment/controller/CommentController.java"
click node_auth_controller "https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/auth/controller/AuthController.java"
click node_workspace_service "https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/workspace/service/impl/WorkspaceServiceImpl.java"
click node_workspace_access "https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/workspace/service/impl/WorkspaceAccessServiceImpl.java"
click node_project_service "https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/project/service/impl/ProjectServiceImpl.java"
click node_task_service "https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/task/service/impl/TaskServiceImpl.java"
click node_comment_service "https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/comment/service/impl/CommentServiceImpl.java"
click node_notification_service "https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/notification/service/impl/NotificationServiceImpl.java"
click node_activity_service "https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/activity/service/impl/ActivityServiceImpl.java"
click node_attachment_service "https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/attachment/service/impl/AttachmentServiceImpl.java"
click node_auth_service "https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/auth/service/impl/AuthServiceImpl.java"
click node_user_store "https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/user/entity/User.java"
click node_workspace_store "https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/workspace/entity/Workspace.java"
click node_project_store "https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/project/entity/Project.java"
click node_task_store "https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/task/entity/Task.java"
click node_security_stack "https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/security/filter/JwtAuthenticationFilter.java"
click node_event_pipeline "https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/messaging/kafka/KafkaProducerService.java"
click node_websocket_channel "https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/messaging/websocket/service/WebSocketNotificationService.java"
click node_common_ops "https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/common/error/GlobalExceptionHandler.java"

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_workhub_app toneBlue
class node_workspace_controller,node_project_controller,node_task_controller,node_comment_controller,node_auth_controller toneAmber
class node_workspace_service,node_workspace_access,node_project_service,node_task_service,node_comment_service,node_notification_service,node_activity_service,node_attachment_service,node_auth_service toneMint
class node_user_store,node_workspace_store,node_project_store,node_task_store,node_collab_store,node_security_stack,node_event_pipeline,node_websocket_channel,node_common_ops toneRose
```

## Components

### Application

Spring Boot entrypoint and runtime setup

- [Workhub](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/WorkhubApplication.java): Spring Boot app · Main application entrypoint. · `src/main/java/com/smj/workhub/WorkhubApplication.java`

### HTTP API

REST ingress and DTO-based request flow

- [Workspace API](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/workspace/controller/WorkspaceController.java): REST controller · Workspace and membership endpoints. · `src/main/java/com/smj/workhub/workspace/controller/WorkspaceController.java`
- [Project API](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/project/controller/ProjectController.java): REST controller · Project endpoints. · `src/main/java/com/smj/workhub/project/controller/ProjectController.java`
- [Task API](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/task/controller/TaskController.java): REST controller · Task endpoints and status flows. · `src/main/java/com/smj/workhub/task/controller/TaskController.java`
- [Comment API](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/comment/controller/CommentController.java): REST controller · Comment creation and updates. · `src/main/java/com/smj/workhub/comment/controller/CommentController.java`
- [Auth API](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/auth/controller/AuthController.java): REST controller · Register and login endpoints. · `src/main/java/com/smj/workhub/auth/controller/AuthController.java`

### Core Domain

Workspace, project, task, and collaboration features

- [Workspace Service](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/workspace/service/impl/WorkspaceServiceImpl.java): domain service · Workspace lifecycle and membership orchestration. · `src/main/java/com/smj/workhub/workspace/service/impl/WorkspaceServiceImpl.java`
- [Access Control](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/workspace/service/impl/WorkspaceAccessServiceImpl.java): authorization service · Workspace membership and role checks. · `src/main/java/com/smj/workhub/workspace/service/impl/WorkspaceAccessServiceImpl.java`
- [Project Service](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/project/service/impl/ProjectServiceImpl.java): domain service · Project lifecycle and filtering logic. · `src/main/java/com/smj/workhub/project/service/impl/ProjectServiceImpl.java`
- [Task Service](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/task/service/impl/TaskServiceImpl.java): domain service · Task assignment, status, and orchestration. · `src/main/java/com/smj/workhub/task/service/impl/TaskServiceImpl.java`
- [Comment Service](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/comment/service/impl/CommentServiceImpl.java): domain service · Comment persistence and event emission. · `src/main/java/com/smj/workhub/comment/service/impl/CommentServiceImpl.java`
- [Notification Service](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/notification/service/impl/NotificationServiceImpl.java): notification service · Notification generation and delivery coordination. · `src/main/java/com/smj/workhub/notification/service/impl/NotificationServiceImpl.java`
- [Activity Service](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/activity/service/impl/ActivityServiceImpl.java): audit service · Activity log creation and querying. · `src/main/java/com/smj/workhub/activity/service/impl/ActivityServiceImpl.java`
- [Attachment Service](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/attachment/service/impl/AttachmentServiceImpl.java): file service · Attachment metadata and persistence. · `src/main/java/com/smj/workhub/attachment/service/impl/AttachmentServiceImpl.java`
- [Auth Service](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/auth/service/impl/AuthServiceImpl.java): identity service · Register and login orchestration. · `src/main/java/com/smj/workhub/auth/service/impl/AuthServiceImpl.java`

### Infrastructure

Security, persistence support, messaging, and cross-cutting concerns

- [User Model](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/user/entity/User.java): user entity/repository · User identity, status, role, and repository boundary. · `src/main/java/com/smj/workhub/user/entity/User.java`
- [Workspace Store](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/workspace/entity/Workspace.java): workspace entity/repository · Workspace, membership, and access persistence. · `src/main/java/com/smj/workhub/workspace/entity/Workspace.java`
- [Project Store](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/project/entity/Project.java): project entity/repository · Project persistence and dynamic specifications. · `src/main/java/com/smj/workhub/project/entity/Project.java`
- [Task Store](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/task/entity/Task.java): task entity/repository · Task persistence and query specifications. · `src/main/java/com/smj/workhub/task/entity/Task.java`
- **Collab Store**: comment/activity/attachment/notification persistence · Shared persistence for collaboration and user-facing event data.
- [JWT Security](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/security/filter/JwtAuthenticationFilter.java): security filter/service · JWT authentication, principal resolution, and security configuration. · `src/main/java/com/smj/workhub/security/filter/JwtAuthenticationFilter.java`
- [Event Pipeline](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/messaging/kafka/KafkaProducerService.java): async messaging · Kafka, processed-event tracking, and async listeners. · `src/main/java/com/smj/workhub/messaging/kafka/KafkaProducerService.java`
- [WebSocket Channel](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/messaging/websocket/service/WebSocketNotificationService.java): real-time delivery · WebSocket fan-out for live updates. · `src/main/java/com/smj/workhub/messaging/websocket/service/WebSocketNotificationService.java`
- [Common Ops](https://github.com/suhasj1231/workhub/blob/main/src/main/java/com/smj/workhub/common/error/GlobalExceptionHandler.java): cross-cutting · Global errors, logging, API docs, async, Redis, and cache support. · `src/main/java/com/smj/workhub/common/error/GlobalExceptionHandler.java`

## Connections

- Workhub → Workspace API: hosts · Application exposes workspace HTTP endpoints.
- Workhub → Project API: hosts · Application exposes project HTTP endpoints.
- Workhub → Task API: hosts · Application exposes task HTTP endpoints.
- Workhub → Comment API: hosts · Application exposes comment HTTP endpoints.
- Workhub → Auth API: hosts · Application exposes auth HTTP endpoints.
- Workspace API → Workspace Service: calls · REST requests are translated into workspace operations.
- Project API → Project Service: calls · REST requests are translated into project operations.
- Task API → Task Service: calls · REST requests are translated into task operations.
- Comment API → Comment Service: calls · REST requests are translated into comment operations.
- Auth API → Auth Service: calls · REST requests are translated into auth flows.
- Workspace Service → Workspace Store: persists · Workspace and membership data are stored through repositories.
- Workspace Service → Access Control: authorizes · Workspace rules are checked during mutations and reads.
- Project Service → Project Store: persists · Project state is read and written via repositories.
- Task Service → Task Store: persists · Task state is read and written via repositories.
- Comment Service → Collab Store: persists · Comments are stored as part of collaboration data.
- Activity Service → Collab Store: persists · Activity logs are stored as collaboration/audit data.
- Attachment Service → Collab Store: persists · Attachment metadata is stored with collaboration data.
- Notification Service → Collab Store: persists · Notifications are stored for later delivery and reads.
- Auth Service → User Model: uses · Authentication works against the user identity model.
- JWT Security → Auth API: protects · JWT security governs access to authenticated endpoints.
- JWT Security → Access Control: guards · Workspace authorization depends on authenticated principals.
- Comment Service → Event Pipeline: publishes · Comment creation emits domain events into the async pipeline.
- Event Pipeline → Notification Service: consumes · Async events can become notifications.
- Event Pipeline → WebSocket Channel: fans out · Async events can be pushed to live clients.
- Notification Service → WebSocket Channel: pushes · Notifications can be delivered in real time.
- Workspace Service → Common Ops: relies on · Shared exceptions, logging, and API support underpin service behavior.
- Project Service → Common Ops: relies on · Shared exceptions, logging, and API support underpin service behavior.
- Task Service → Common Ops: relies on · Shared exceptions, logging, and API support underpin service behavior.
