A modern, real-time collaborative development platform built with Spring Boot and modern web technologies. Devchat provides project management, issue tracking, team collaboration, and real-time activity tracking with complete user isolation.
- Project Management: Create, manage, and track development projects with user isolation
- Issue Tracking: Comprehensive issue management with priority, status, and assignment
- Real-time Updates: Live notifications and updates across the platform
- User Management: User profiles, authentication, and role-based access
- Dashboard: Centralized overview of projects, issues, and recent activity
- Recent Activity: User-specific activity tracking and timeline
- Real-time Chat: WebSocket-based messaging system with persistence
- Settings Management: User preferences and profile customization
- Multi-tenant Architecture: Each user has their own isolated data
- User Context Management: Automatic user context for all operations
- Secure Authentication: JWT-based authentication with password encryption
- Data Privacy: Users can only access their own projects, issues, and messages
- Activity Tracking: User-specific recent activity and notifications
- Live Updates: Real-time project and issue updates
- Instant Notifications: Real-time notifications for team activities
- WebSocket Integration: Efficient bidirectional communication
- Event-driven Architecture: Decoupled real-time event handling
- Activity Stream: Real-time activity tracking and display
- Java 21: Latest LTS version with modern language features
- Spring Boot 3.5.0: Rapid application development framework
- Spring Security: Authentication and authorization
- Spring Data JPA: Data access layer with Hibernate
- PostgreSQL: Primary database with Flyway migrations
- WebSocket: Real-time communication with STOMP
- BCrypt: Password encryption
- Lombok: Reduces boilerplate code
- Maven: Dependency management and build tool
- Vanilla JavaScript (ES6+): Modern JavaScript with ES6 modules
- TailwindCSS: Utility-first CSS framework
- HTML5: Semantic markup
- CSS3: Modern styling with custom properties
- WebSocket Client: Real-time communication
- Local Storage: Client-side data persistence
- Flyway: Database migration management
- PostgreSQL: Relational database
- Maven: Build automation and dependency management
Devchat includes a comprehensive suite of unit and integration tests to ensure code quality and reliability.
- Test Framework: JUnit 5 (Jupiter)
- Test Runner: Maven Surefire Plugin
- Mocking: Mockito, Spring Boot Test
- Database: H2 in-memory for integration tests
- Entities: JPA entity mapping and constraints
- Repositories: Data access and query methods
- Services: Business logic, authentication, and authorization
- Controllers: REST API endpoints, request/response validation, security
- Mappers: DTO/entity conversion
- Exception Handling: Custom exception logic
To run all tests:
mvn testTest results will be shown in the console and detailed reports are available in target/surefire-reports/.
- Place new test classes in
src/test/java/com/Devchat/ - Use
@SpringBootTestfor integration tests,@WebMvcTestfor controller tests, and@DataJpaTestfor repository tests - Use
@MockBeanto mock dependencies as needed - For controller tests, add the
X-User-IDheader to simulate authentication:mockMvc.perform(post("/api/projects/create") .header("X-User-ID", "1") ...)
- Mock
UserService.getUserByIdto return a test user for the given ID
See the provided test templates for examples:
ControllerTemplateTest.javaServiceTemplateTest.javaRepositoryTemplateTest.javaMapperTemplateTest.javaEntityTemplateTest.javaExceptionTemplateTest.java
Devchat/
βββ src/
β βββ main/
β β βββ java/com/Devchat/
β β β βββ config/ # Configuration classes
β β β β βββ Appconfig.java
β β β β βββ CorsConfig.java
β β β β βββ securityconfig.java
β β β β βββ WebSocketConfig.java
β β β β βββ UserContextInterceptor.java
β β β βββ constants/ # Application constants
β β β β βββ ProjectConstants.java
β β β βββ Controller/ # REST API controllers
β β β β βββ Hello.java
β β β β βββ IssueController.java
β β β β βββ MessageController.java
β β β β βββ ProjectController.java
β β β β βββ RoleController.java
β β β β βββ UpdateController.java
β β β β βββ UserController.java
β β β βββ DTO/ # Data Transfer Objects
β β β β βββ AuthresponseDTO.java
β β β β βββ CreateMessageRequest.java
β β β β βββ ErrorresponseDTO.java
β β β β βββ IssueDTO.java
β β β β βββ LoginDTO.java
β β β β βββ MessageDTO.java
β β β β βββ ProjectCreateRequest.java
β β β β βββ ProjectDTO.java
β β β β βββ ProjectMemberDTO.java
β β β β βββ RegisterDTO.java
β β β β βββ RoleDTO.java
β β β β βββ UserprofileDTO.java
β β β βββ entity/ # JPA entities
β β β β βββ Issue.java
β β β β βββ Message.java
β β β β βββ Project.java
β β β β βββ ProjectMember.java
β β β β βββ Role.java
β β β β βββ Update.java
β β β β βββ User.java
β β β βββ exceptions/ # Custom exceptions
β β β β βββ InvalidProjectDataException.java
β β β β βββ ProjectNotFoundException.java
β β β β βββ RoleNotFoundException.java
β β β βββ mapper/ # Object mappers
β β β β βββ ProjectMapper.java
β β β β βββ RoleMapper.java
β β β βββ repository/ # Data access layer
β β β β βββ IssueRepository.java
β β β β βββ MessageRepository.java
β β β β βββ ProjectRepository.java
β β β β βββ RoleRepository.java
β β β β βββ UpdateRepository.java
β β β β βββ UserRepository.java
β β β βββ Service/ # Business logic layer
β β β β βββ Dataloader.java
β β β β βββ IssueService.java
β β β β βββ IssueServiceImpl.java
β β β β βββ MessageService.java
β β β β βββ MessageServiceImpl.java
β β β β βββ ProjectService.java
β β β β βββ ProjectServiceImpl.java
β β β β βββ RoleService.java
β β β β βββ UpdateService.java
β β β β βββ UpdateServiceImpl.java
β β β β βββ UserService.java
β β β β βββ UserServiceImpl.java
β β β βββ util/ # Utility classes
β β β βββ jwtUtil.java
β β β βββ UserContext.java
β β βββ resources/
β β βββ application.properties # Application configuration
β β βββ static/ # Frontend assets (served by Spring Boot)
β β β βββ pages/ # HTML pages
β β β βββ js/ # JavaScript modules
β β β βββ css/ # Stylesheets
β β β βββ test-activity.html # Testing page
β β βββ db/migration/ # Database migrations
β βββ test/ # Test classes
βββ Frontend/ # Frontend source (development)
β βββ dist/
β βββ pages/ # HTML pages
β βββ js/ # JavaScript modules
β βββ css/ # Stylesheets
βββ pom.xml # Maven configuration
βββ README.md # Project documentation
Devchat implements a multi-tenant architecture where each user has complete data isolation:
@Component
public class UserContext {
private static final ThreadLocal<User> currentUser = new ThreadLocal<>();
public static void setCurrentUser(User user) {
currentUser.set(user);
}
public static User getCurrentUser() {
return currentUser.get();
}
public static Long getCurrentUserId() {
User user = getCurrentUser();
return user != null ? user.getId() : null;
}
}@Component
public class UserContextInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
String userId = request.getHeader("X-User-ID");
if (userId != null && !userId.trim().isEmpty()) {
try {
Long id = Long.parseLong(userId);
User user = userService.getUserById(id);
UserContext.setCurrentUser(user);
} catch (Exception e) {
System.out.println("Failed to set user context: " + e.getMessage());
}
}
return true;
}
}The application follows a 3-tier layered architecture:
-
Presentation Layer (Controllers)
- REST API endpoints with user authentication
- Request/response handling
- Input validation and error handling
-
Business Logic Layer (Services)
- Business rules implementation with user isolation
- Transaction management
- Data processing and validation
-
Data Access Layer (Repositories)
- Database operations with user filtering
- Entity management
- Query optimization
public interface ProjectRepository extends JpaRepository<Project, Long> {
List<Project> findByCreatedById(Long userId);
List<Project> findByStatusAndCreatedById(String status, Long userId);
}@Service
@Transactional
public class ProjectServiceImpl implements ProjectService {
public List<ProjectDTO> getAllProjects() {
Long currentUserId = UserContext.getCurrentUserId();
List<Project> projects = projectRepository.findByCreatedById(currentUserId);
return projects.stream()
.map(projectMapper::toDTO)
.collect(Collectors.toList());
}
}@Data
@NoArgsConstructor
@AllArgsConstructor
public class ProjectDTO {
private Long id;
private String name;
private String description;
private String status;
private LocalDateTime createdAt;
private Long createdById;
}// Frontend real-time manager
realtimeManager.subscribe("projects", (data) => {
if (data.action === "created" || data.action === "updated") {
loadRecentProjects();
loadRecentActivity();
}
});public enum ProjectStatus {
ACTIVE, PLANNING, COMPLETED, ON_HOLD
}
public enum IssueStatus {
OPEN, IN_PROGRESS, RESOLVED, CLOSED
}<!-- Spring Boot Starters -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<!-- Database -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<!-- Security -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.5</version>
</dependency>
<!-- Utilities -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>- Users: User accounts and profiles with authentication
- Projects: Development projects with user-specific ownership
- Issues: Project issues with user-specific assignment and reporting
- Messages: Real-time chat messages with user-specific conversations
- Roles: User roles and permissions
- Updates: Real-time activity tracking with user isolation
- Users own their projects (one-to-many)
- Projects contain issues (one-to-many)
- Issues are assigned to users (many-to-one)
- Users send/receive messages (many-to-many)
- Updates track user-specific activities (one-to-many)
- JWT Authentication: Stateless token-based authentication
- BCrypt Password Encryption: Secure password hashing
- User Context Management: Automatic user isolation
- CORS Configuration: Cross-origin resource sharing setup
- Input Validation: Request validation and sanitization
- Role-based Access: User role management
- Secure Headers: Security headers configuration
POST /api/auth/register- User registrationPOST /api/auth/login- User loginGET /api/auth/all- Get all users (admin only)
GET /api/projects- Get user's projectsPOST /api/projects/create- Create new projectGET /api/projects/{id}- Get project by ID (user's projects only)PUT /api/projects/{id}- Update project (user's projects only)DELETE /api/projects/{id}- Delete project (user's projects only)
GET /api/issues- Get user's issuesPOST /api/issues- Create new issueGET /api/issues/{id}- Get issue by ID (user's issues only)PUT /api/issues/{id}- Update issue (user's issues only)DELETE /api/issues/{id}- Delete issue (user's issues only)
GET /api/updates/recent- Get user's recent activityGET /api/updates/since/{timestamp}- Get updates since timestamp
GET /api/messages/public/recent- Get recent public messagesGET /api/messages/conversation- Get conversation between usersPUT /api/messages/{id}/read- Mark message as read
GET /api/users/profile- Get user profilePUT /api/users/profile- Update user profilePUT /api/users/password- Change passwordDELETE /api/users/account- Delete account
- Connection:
ws://localhost:8080/chat-websocket - Protocol: STOMP over SockJS
- Features: Public chat, private messaging, typing indicators
- Persistence: All messages saved to database
- Project Updates: Live project creation, updates, and deletion
- Issue Updates: Real-time issue status changes and assignments
- Activity Stream: Live activity tracking and notifications
- User Notifications: Instant notifications for team activities
// Subscribe to real-time updates
realtimeManager.subscribe("projects", (data) => {
console.log("Project update:", data);
loadRecentProjects();
loadRecentActivity();
});
realtimeManager.subscribe("issues", (data) => {
console.log("Issue update:", data);
loadRecentIssues();
loadRecentActivity();
});- ES6 Modules: Modern JavaScript with import/export
- Component-based: Modular UI components
- Real-time Integration: WebSocket and REST API integration
- User Context: Automatic user ID management
- api.js: Centralized API utilities with authentication
- dashboard.js: Dashboard functionality and real-time updates
- project.js: Project management with user isolation
- issue.js: Issue management with user isolation
- chat.js: Real-time messaging system
- realtime.js: Real-time update management
// Login and store user context
const response = await fetch("/api/auth/login", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(loginData),
});
const data = await response.json();
localStorage.setItem("userId", data.userProfile.id);
localStorage.setItem("username", data.userProfile.username);
// Use authFetch for authenticated requests
const projects = await authFetch("/api/projects");# Run all tests
mvn test
# Run specific test class
mvn test -Dtest=ProjectServiceTest
# Run with coverage
mvn jacoco:report- Manual Testing: Use test-activity.html for API testing
- Browser Testing: Test real-time features in browser
- User Isolation Testing: Verify data isolation between users
- Database Indexing: Optimized queries with user-specific indexing
- Connection Pooling: HikariCP for database connection management
- Caching: Spring Boot caching for frequently accessed data
- Real-time Updates: Efficient WebSocket communication
- Frontend Optimization: Modular JavaScript with lazy loading
- User Isolation: Efficient filtering by user ID
- User-specific Activity: Each user sees only their own activity
- Real-time Updates: Activity updates in real-time
- Comprehensive Tracking: Tracks projects, issues, and user actions
- Timeline Display: Chronological activity display
- Project Creation: When users create new projects
- Project Updates: When projects are modified
- Project Deletion: When projects are deleted
- Issue Creation: When issues are created
- Issue Updates: When issues are modified
- Issue Resolution: When issues are resolved
@Service
public class UpdateServiceImpl implements UpdateService {
public void recordUpdate(String type, String action, Long entityId, String entityName) {
Long currentUserId = UserContext.getCurrentUserId();
Update update = new Update();
update.setType(type);
update.setAction(action);
update.setEntityId(entityId);
update.setEntityName(entityName);
update.setUserId(currentUserId);
update.setCreatedAt(LocalDateTime.now());
updateRepository.save(update);
}
}