How suhasj1231/workhub works
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: WorkhubApplication.java Workhub · WorkspaceServiceImpl.java Workspace Service · ProjectServiceImpl.java Project Service · TaskServiceImpl.java Task Service
Components 24
Application
Spring Boot entrypoint and runtime setup
- Workhub · Main application entrypoint.
src/main/java/com/smj/workhub/WorkhubApplication.java
HTTP API
REST ingress and DTO-based request flow
- Workspace API · Workspace and membership endpoints.
src/main/java/com/smj/workhub/workspace/controller/WorkspaceController.java - Project API · Project endpoints.
src/main/java/com/smj/workhub/project/controller/ProjectController.java - Task API · Task endpoints and status flows.
src/main/java/com/smj/workhub/task/controller/TaskController.java - Comment API · Comment creation and updates.
src/main/java/com/smj/workhub/comment/controller/CommentController.java - Auth API · Register and login endpoints.
src/main/java/com/smj/workhub/auth/controller/AuthController.java
Core Domain
Workspace, project, task, and collaboration features
- Workspace Service · Workspace lifecycle and membership orchestration.
src/main/java/com/smj/workhub/workspace/service/impl/WorkspaceServiceImpl.java - Access Control · Workspace membership and role checks.
src/main/java/com/smj/workhub/workspace/service/impl/WorkspaceAccessServiceImpl.java - Project Service · Project lifecycle and filtering logic.
src/main/java/com/smj/workhub/project/service/impl/ProjectServiceImpl.java - Task Service · Task assignment, status, and orchestration.
src/main/java/com/smj/workhub/task/service/impl/TaskServiceImpl.java - Comment Service · Comment persistence and event emission.
src/main/java/com/smj/workhub/comment/service/impl/CommentServiceImpl.java - Notification Service · Notification generation and delivery coordination.
src/main/java/com/smj/workhub/notification/service/impl/NotificationServiceImpl.java - Activity Service · Activity log creation and querying.
src/main/java/com/smj/workhub/activity/service/impl/ActivityServiceImpl.java - Attachment Service · Attachment metadata and persistence.
src/main/java/com/smj/workhub/attachment/service/impl/AttachmentServiceImpl.java - Auth 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 · User identity, status, role, and repository boundary.
src/main/java/com/smj/workhub/user/entity/User.java - Workspace Store · Workspace, membership, and access persistence.
src/main/java/com/smj/workhub/workspace/entity/Workspace.java - Project Store · Project persistence and dynamic specifications.
src/main/java/com/smj/workhub/project/entity/Project.java - Task Store · Task persistence and query specifications.
src/main/java/com/smj/workhub/task/entity/Task.java - Collab Store · Shared persistence for collaboration and user-facing event data.
- JWT Security · JWT authentication, principal resolution, and security configuration.
src/main/java/com/smj/workhub/security/filter/JwtAuthenticationFilter.java - Event Pipeline · Kafka, processed-event tracking, and async listeners.
src/main/java/com/smj/workhub/messaging/kafka/KafkaProducerService.java - WebSocket Channel · WebSocket fan-out for live updates.
src/main/java/com/smj/workhub/messaging/websocket/service/WebSocketNotificationService.java - Common Ops · Global errors, logging, API docs, async, Redis, and cache support.
src/main/java/com/smj/workhub/common/error/GlobalExceptionHandler.java
Connections 28
- 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.