Skip to content
This repository was archived by the owner on Sep 23, 2025. It is now read-only.

Adam-Etyang/Devchat

Repository files navigation

Devchat - Collaborative Development Platform

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.

πŸš€ Features

Core Features

  • 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

User Isolation & Security

  • 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

Real-time Features

  • 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

πŸ›  Technology Stack

Backend

  • 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

Frontend

  • 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

Development Tools

  • Flyway: Database migration management
  • PostgreSQL: Relational database
  • Maven: Build automation and dependency management

Testing

Unit & Integration Tests

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

Test Coverage

  • 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

Running Tests

To run all tests:

mvn test

Test results will be shown in the console and detailed reports are available in target/surefire-reports/.

Writing New Tests

  • Place new test classes in src/test/java/com/Devchat/
  • Use @SpringBootTest for integration tests, @WebMvcTest for controller tests, and @DataJpaTest for repository tests
  • Use @MockBean to mock dependencies as needed
  • For controller tests, add the X-User-ID header to simulate authentication:
    mockMvc.perform(post("/api/projects/create")
        .header("X-User-ID", "1")
        ...)
  • Mock UserService.getUserById to return a test user for the given ID

See the provided test templates for examples:

  • ControllerTemplateTest.java
  • ServiceTemplateTest.java
  • RepositoryTemplateTest.java
  • MapperTemplateTest.java
  • EntityTemplateTest.java
  • ExceptionTemplateTest.java

πŸ“ Project Structure

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

πŸ— Architecture & Design Patterns

Multi-tenant Architecture with User Isolation

Devchat implements a multi-tenant architecture where each user has complete data isolation:

User Context Management

@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;
    }
}

User Context Interceptor

@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;
    }
}

Layered Architecture

The application follows a 3-tier layered architecture:

  1. Presentation Layer (Controllers)

    • REST API endpoints with user authentication
    • Request/response handling
    • Input validation and error handling
  2. Business Logic Layer (Services)

    • Business rules implementation with user isolation
    • Transaction management
    • Data processing and validation
  3. Data Access Layer (Repositories)

    • Database operations with user filtering
    • Entity management
    • Query optimization

Design Patterns

1. Repository Pattern with User Isolation

public interface ProjectRepository extends JpaRepository<Project, Long> {
    List<Project> findByCreatedById(Long userId);
    List<Project> findByStatusAndCreatedById(String status, Long userId);
}

2. Service Layer Pattern with User Context

@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());
    }
}

3. DTO Pattern for Data Transfer

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ProjectDTO {
    private Long id;
    private String name;
    private String description;
    private String status;
    private LocalDateTime createdAt;
    private Long createdById;
}

4. Observer Pattern for Real-time Updates

// Frontend real-time manager
realtimeManager.subscribe("projects", (data) => {
  if (data.action === "created" || data.action === "updated") {
    loadRecentProjects();
    loadRecentActivity();
  }
});

5. Strategy Pattern for Status Management

public enum ProjectStatus {
    ACTIVE, PLANNING, COMPLETED, ON_HOLD
}

public enum IssueStatus {
    OPEN, IN_PROGRESS, RESOLVED, CLOSED
}

πŸ”§ Dependencies

Core Dependencies

<!-- 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>

πŸ—„ Database Schema

Core Entities with User Isolation

  • 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

Key Relationships

  • 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)

πŸ” Security Features

  • 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

🌐 API Endpoints

Authentication

  • POST /api/auth/register - User registration
  • POST /api/auth/login - User login
  • GET /api/auth/all - Get all users (admin only)

Projects (User-isolated)

  • GET /api/projects - Get user's projects
  • POST /api/projects/create - Create new project
  • GET /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)

Issues (User-isolated)

  • GET /api/issues - Get user's issues
  • POST /api/issues - Create new issue
  • GET /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)

Recent Activity (User-isolated)

  • GET /api/updates/recent - Get user's recent activity
  • GET /api/updates/since/{timestamp} - Get updates since timestamp

Messaging

  • GET /api/messages/public/recent - Get recent public messages
  • GET /api/messages/conversation - Get conversation between users
  • PUT /api/messages/{id}/read - Mark message as read

User Management

  • GET /api/users/profile - Get user profile
  • PUT /api/users/profile - Update user profile
  • PUT /api/users/password - Change password
  • DELETE /api/users/account - Delete account

πŸ’¬ Real-time Features

WebSocket Messaging

  • Connection: ws://localhost:8080/chat-websocket
  • Protocol: STOMP over SockJS
  • Features: Public chat, private messaging, typing indicators
  • Persistence: All messages saved to database

Real-time Updates

  • 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

Event-driven Architecture

// 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();
});

🎨 Frontend Architecture

Modular JavaScript

  • 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

Key Frontend Modules

  • 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

Authentication Flow

// 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");

πŸ§ͺ Testing

Backend Testing

# Run all tests
mvn test

# Run specific test class
mvn test -Dtest=ProjectServiceTest

# Run with coverage
mvn jacoco:report

Frontend Testing

  • 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

πŸ“Š Performance Considerations

  • 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

πŸ”„ Recent Activity System

Features

  • 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

Activity Types

  • 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

Implementation

@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);
    }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors