Skip to content

Commit 2e5b835

Browse files
PredixxsindiibbSindiBuklajigithub-actions[bot]az108
authored
General: Fix not working everything (#74)
* Implement ContributionBalanceCalculator (part 1) for calculating CQI * Implement PairingSignalsCalculator for CQI and add unit tests * chore: formatting issues * fix:pipeline error * Add startup scripts for React, PostgreSQL, and Spring Boot servers * Implement project management features: add project properties, update API endpoints, and enhance UI for project selection * fix: AnalysisResource and RequestResource with correct endpoints and configuration properties * chore: update OpenAPI spec and generated client * Enhance repository analysis and streaming capabilities: - Add analyzeRepository method to GitContributionAnalysisService for streamlined contribution analysis. - Implement loadBasicTeamDataStream for real-time team data fetching in Teams component. - Update RequestService to clear database before saving results and improve repository processing. - Introduce StreamResource for SSE streaming of repository analysis results. - Adjust tests to accommodate new method signatures and functionality. * Enhance test configurations and update repository fetching parameters: add test logging and modify repository IDs in tests * Remove multiple subprojects from the repository, cleaning up unused or obsolete directories to streamline the project structure. * Add 'repos/' to .gitignore to exclude repository directories from version control * Update git-repo-path comment in application.yml to clarify usage and .gitignore update * feat: Add CQI and isSuspicious fields to ClientResponseDTO - Add cqi: Double field to represent collaboration quality index - Add isSuspicious: Boolean field to flag unusual team activity - Update DTO to include server-calculated team quality metrics * feat: Implement server-side CQI calculation in RequestService - Inject ContributionBalanceCalculator dependency - Calculate CQI for each team using contribution balance scores - Update ClientResponseDTO to include cqi and isSuspicious values - Pass calculated metrics to client via streaming and database APIs * feat: Add getData endpoint to RequestResource - Expose new GET /api/requestResource/getData endpoint - Retrieve pre-analyzed team data from database without re-analysis - Provides fallback for loading cached team metrics * feat: Add exerciseId parameter to cloneTeamRepository - Accept exerciseId parameter to lookup exercise-specific git repo path - Support multiple exercises with different repository configurations - Read gitRepoPath from HarmoniaProperties based on exerciseId * refactor: Add gitRepoPath parameter to GitOperationsService - Pass gitRepoPath as parameter instead of reading from config - Support exercise-specific repository storage paths - Improve flexibility for multi-exercise scenarios * chore: Improve logging in ArtemisClientService - Add detailed VCS access log debugging information - Log action types and sample entries for troubleshooting - Improve error messages with participation context * config: Remove redundant exercise configuration from app properties - Remove exerciseId and gitRepoPath from global Artemis config - These are now exercise-specific in harmonia.projects config - Simplifies configuration management for multiple exercises * chore: Update ClientResponseDTO type definitions - Add cqi property for collaboration quality index - Add isSuspicious property for team anomaly detection - Regenerated from OpenAPI schema * chore: Update RequestResourceApi generated code - Add getData() method to RequestResourceApi client - Support retrieving cached team data from server - Regenerated from updated OpenAPI schema * feat: Use server-calculated CQI metrics in data loaders - Add team caching to ensure consistent metrics across views - Transform ComplexTeamData using server-provided CQI values - Remove client-side CQI recalculation, use server as source-of-truth - Update stream handler to emit ComplexTeamData with full metrics - Add teamCache to prevent duplicate transformations - Update terminology: backend server in comments * feat: Implement React Query caching for teams list - Add useQuery hook to cache teams per exercise with infinite staleTime - Prevent unnecessary re-fetching when navigating back - Check cache before initiating SSE stream - Update React Query cache in real-time as teams stream in - Invalidate cache only on explicit reanalysis request * fix: Use cached team data instead of re-fetching on detail view - Pass team object via route state from Teams page - Eliminate redundant API call that fetches fresh data - Ensures CQI metrics are consistent between list and detail views - Simplify component by removing useQuery and loading states * chore: update OpenAPI spec and generated client * Refactor VCS log filtering to include multiple valid actions * refactor: simplify log filtering comment in ArtemisClientService * feat: add CQI calculation to repository processing in RequestService * refactor: improve code readability and add missing Javadoc comments * refactor: simplify arrow function syntax and improve code formatting in StartAnalysis, dataLoaders, and Teams components * feat: add H2 database configuration for in-memory testing and update OpenAPI arguments * fix: update OpenAPI generator configuration and improve code readability * fix failing workflow * fix: improve parallel processing of repository cloning and update exercise ID in configuration * feat: implement custom hook for team data streaming and refactor project fetching logic * Implement LLM-based effort rating and fairness analysis features - Added EffortRatingDTO to encapsulate effort ratings for commit chunks, including methods for calculating weighted effort and generating trivial/disabled ratings. - Introduced FairnessFlag enum to identify potential fairness issues in team contributions. - Created FairnessReportDTO to represent the final fairness analysis report, including author details and analysis metadata. - Developed CommitChunkerService to handle commit chunking for LLM analysis, including methods for bundling small commits and chunking large commits. - Implemented unit tests for CommitChunkDTO, EffortRatingDTO, FairnessReportDTO, and CommitChunkerService to ensure functionality and correctness. * feat: add CommitEffortRaterService for LLM-based effort rating and implement unit tests * fix: ensure null check for diff in truncateDiff method is properly enclosed * fix: Enable OpenAPI generation in CI - Add OpenApiConfiguration with mock ChatClient and ChatModel beans for openapi profile - Enable Liquibase in openapi profile to initialize database schema - Update generated OpenAPI spec - Fix checkstyle violations with proper JavaDoc This fixes the failing 'Validate and Autocommit OpenAPI Spec & Client Code' CI check. * chore: update OpenAPI spec and generated client * feat: implement contribution fairness analysis service and REST controller * feat: enhance CORS configuration and improve secure cookie handling in AuthResource * refactor: improve commit author mapping logic in ContributionFairnessService * fix: enhance response parsing in CommitClassifierService to handle optional whitespace and remove markdown code blocks * feat: implement activity logging and enhance team streaming with log handling * fix: remove ActivityLog component and related logging functionality from TeamsList and hooks * feat: add AI analysis feature with detailed chunk analysis and frontend integration * fix: update .gitignore to include local directory and configure AI base URL in docker-compose * chore: update OpenAPI spec and generated client * feat: integrate LLM model selection and configuration in AI services, add endpoints for model management * fix: improve code documentation and formatting in various service and resource classes * feat: Implement analysis status management and UI components - Added AnalysisState enum to represent possible states of analysis. - Created AnalysisStatus entity to persist analysis state in the database. - Developed AnalysisStatusDTO for transferring analysis status data. - Implemented AnalysisStatusRepository for database operations. - Created AnalysisStateService to manage analysis lifecycle, including starting, updating, completing, and cancelling analyses. - Added REST endpoints in AnalysisResource for fetching and manipulating analysis status. - Introduced useAnalysisStatus hook for polling analysis status from the server. - Updated Teams component to utilize new analysis status management features. - Created ActivityLog component to display current analysis progress. - Added ConfirmationDialog component for user confirmations. - Implemented alert dialog UI components for better user interaction. - Updated tests for AnalysisStateService and AnalysisResource to ensure correct functionality. - Created Liquibase changelog for analysis_status table creation. * fix: add database availability check before starting the server * chore: update OpenAPI spec and generated client * fix: add LM Studio availability check and handle zero commits in contribution balance calculation * fix: enhance analysis state management and improve directory clearing logic * fix: update total commits calculation to sum student commit counts * feat: implement analyzed chunks persistence and retrieval in RequestService * feat: add error handling for analyzed chunks and update UI components to display errors * feat: implement orphan commit tracking and analysis in GitContributionAnalysisService and related components * feat: add CQI and isSuspicious fields to TeamParticipation and update related logic in RequestService * feat: enhance analysis pipeline with integration tests and improved error handling * feat: enhance integration test logging and relax effort score assertion for trivial changes * feat: enhance JSON parsing with repair logic for truncated responses * style: fix client and server style violations * docs: update README with testing and credentials instructions * docs: add LM Studio setup instructions to README * fix openapi workflow * fix client workflow * fix openapi workflow * chore: update OpenAPI spec and generated client * feat: add FairnessFlag enum to identify potential fairness issues and update related DTOs and tests * style: simplify regex pattern usage in CommitClassifierService * fix: remove unnecessary localhost origins from CORS configuration * fix: change var to List<String> for actionTypes in ArtemisClientService * fix: add analyzed_chunks table and remove obsolete changelog files * fix: update comments to replace 'frontend' with 'client' and 'backend' with 'server' * fix: update analysis history mapping to use AnalyzedChunkDTO and provide default values * fix: handle errors in loadBasicTeamDataStream by invoking onError callback * fix: refactor analysis status handling to use generated API and improve error handling * fix: update AnalysisResourceTest to use ResponseEntity for consistency in return types * fix: add JsonInclude annotation to OrphanCommitDTO and RepositoryAnalysisResultDTO for null value handling * fix: refactor linesChanged calculation in OrphanCommitDTO to use DtoUtils for consistency * fix: simplify ObjectMapper and JsonNode usage in AiResource for improved readability * fix: add calculateWeightedEffort method to DtoUtils and refactor EffortRatingDTO to use it * fix: refactor password decryption to use CredentialUtils and remove redundant methods * move dtoutils * client style fix --------- Co-authored-by: Sindi Buklaji <ge43yif@mytum.de> Co-authored-by: SindiBuklaji <sindibukli@outlook.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Aniruddh Zaveri <92953467+az108@users.noreply.github.com> Co-authored-by: Cathy <catherine.kalra@tum.de> Co-authored-by: aniruddhzaveri <aniruddh.zaveri@tum.de>
1 parent 2a06120 commit 2e5b835

117 files changed

Lines changed: 8786 additions & 486 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/auto-generate-openapi.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,6 @@ jobs:
5656
- name: Generate OpenAPI Spec
5757
env:
5858
SPRING_PROFILES_ACTIVE: openapi
59-
SPRING_DATASOURCE_URL: jdbc:postgresql://localhost:5432/harmonia
60-
SPRING_DATASOURCE_USERNAME: postgres
61-
SPRING_DATASOURCE_PASSWORD: harmonia
62-
SPRING_DATASOURCE_DRIVER_CLASS_NAME: org.postgresql.Driver
63-
SPRING_JPA_HIBERNATE_DDL_AUTO: none
64-
SPRING_LIQUIBASE_ENABLED: false
65-
SPRING_DOCKER_COMPOSE_ENABLED: false
6659
run: ./gradlew generateApiDocs -x webapp
6760

6861
- name: Generate Client Code

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,8 @@ out/
3737
.vscode/
3838

3939
Projects/
40+
repos/
4041
test-credentials.properties
42+
.env.integration-test
4143
/.DS_Store
44+
local/

README.md

Lines changed: 89 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ metrics into a single platform, enabling course staff to ensure fair and evidenc
1414

1515
### Key Features
1616

17-
* **On-Demand Analysis:** Instructors can trigger a new analysis job course-wide or per-team, with a high-performance
17+
- **On-Demand Analysis:** Instructors can trigger a new analysis job course-wide or per-team, with a high-performance
1818
target completion time of $\sim 15$ minutes for typical course sizes ($\sim 200$ teams).
19-
* **Teams Overview Table:** A sortable and filterable dashboard of all teams, featuring key metrics:
20-
* **Course Averages** are prominently displayed to provide context for team-specific scores.
21-
* Quantitative data like **Total Commits**, **Lines Written**, and **Team Members**.
22-
* **Collaboration Quality Index (CQI)** (0-100 score).
23-
* **Team Detail View:** An in-depth page providing comprehensive collaboration evidence, including:
24-
* The final **CQI** and all contributing sub-scores.
25-
* A concise, AI-generated **Short Narrative Report** summarizing activity and referencing key commits.
19+
- **Teams Overview Table:** A sortable and filterable dashboard of all teams, featuring key metrics:
20+
- **Course Averages** are prominently displayed to provide context for team-specific scores.
21+
- Quantitative data like **Total Commits**, **Lines Written**, and **Team Members**.
22+
- **Collaboration Quality Index (CQI)** (0-100 score).
23+
- **Team Detail View:** An in-depth page providing comprehensive collaboration evidence, including:
24+
- The final **CQI** and all contributing sub-scores.
25+
- A concise, AI-generated **Short Narrative Report** summarizing activity and referencing key commits.
2626

2727
---
2828

@@ -33,7 +33,7 @@ Harmonia is built as a Java/Spring-based monolith, prioritizing stability and jo
3333
## 💻 Technology Stack
3434

3535
| Component | Technology |
36-
|:----------|:-----------------------------|
36+
| :-------- | :--------------------------- |
3737
| Client | React 19.2 + TypeScript |
3838
| Server | Spring Boot (Jave) |
3939
| Database | PostgreSQL 18 with Hibernate |
@@ -60,7 +60,7 @@ Use the provided startup scripts for an automated setup:
6060
**Windows (PowerShell):**
6161

6262
```powershell
63-
.\scripts\docker_start.ps1
63+
.\scripts\docker_start.ps1
6464
```
6565

6666
The scripts will:
@@ -82,9 +82,9 @@ Alternatively, you can manually build and launch everything:
8282
```
8383

8484
2. Access the services:
85-
* Client (served by nginx): http://localhost:5173
86-
* Spring Boot server: http://localhost:8080
87-
* PostgreSQL: localhost:5432 (user `postgres`, password `harmonia`)
85+
- Client (served by nginx): http://localhost:5173
86+
- Spring Boot server: http://localhost:8080
87+
- PostgreSQL: localhost:5432 (user `postgres`, password `harmonia`)
8888

8989
The Compose setup builds the Gradle boot jar inside `docker/server.Dockerfile`, bundles the React client with Vite via
9090
`docker/client.Dockerfile`, and proxies `/api` + `/actuator` calls from nginx to the server container. All images
@@ -106,17 +106,85 @@ following commands to build and run the server locally:
106106
1. Make sure to run the Docker container.
107107

108108
2. **Build the Project:** Compile the server application.
109-
```bash
109+
110+
```bash
110111
./gradlew clean build -x test
111112
```
112113

113114
3. **Run the Server:** Start the Spring Boot application.
114-
```bash
115+
116+
```bash
115117
./gradlew bootRun
116118
```
117119

118120
---
119121

122+
## 🧪 Testing & Code Quality
123+
124+
Harmonia enforces strict code quality standards for both the server (Java) and client (TypeScript).
125+
126+
### Server (Java)
127+
128+
1. **Run Unit Tests:**
129+
130+
```bash
131+
./gradlew test
132+
```
133+
134+
2. **Run Integration Tests (with Credentials):**
135+
These tests require external services (e.g., Artemis, LLM) and credentials.
136+
137+
_Setup:_ Create `src/test/resources/test-credentials.properties` or set environment variables (`ARTEMIS_TEST_URL`, etc.).
138+
139+
```bash
140+
./gradlew integrationTest
141+
```
142+
143+
3. **Check Code Style (Spotless & Checkstyle):**
144+
145+
```bash
146+
./gradlew spotlessCheck checkstyleMain
147+
```
148+
149+
4. **Auto-fix Formatting Issues:**
150+
```bash
151+
./gradlew spotlessApply
152+
```
153+
154+
### 🤖 Local AI Setup (LM Studio)
155+
156+
For local development or running integration tests that require an LLM, we recommend using [LM Studio](https://lmstudio.ai/).
157+
158+
1. **Download & Install:** Install LM Studio.
159+
2. **Download Model:** Search for and download `google/gemma-3-1b`.
160+
3. **Load Model:** In the AI Chat or Local Server tab, load the `google/gemma-3-1b` model.
161+
4. **Configure Context Length:** In the "Configuration" sidebar, set the **Context Length** to `16384` (16k).
162+
5. **Start Server:** Ensure the Local Server is running (usually on `http://localhost:1234`).
163+
164+
### Client (TypeScript)
165+
166+
Navigate to the webapp directory first: `cd src/main/webapp`
167+
168+
1. **Run Type Checking:**
169+
170+
```bash
171+
npm run compile:ts
172+
```
173+
174+
2. **Check Code Style (Prettier & ESLint):**
175+
176+
```bash
177+
npm run prettier:check
178+
npm run lint
179+
```
180+
181+
3. **Auto-fix Formatting Issues:**
182+
```bash
183+
npm run prettier:fix
184+
```
185+
186+
---
187+
120188
## 📘 OpenAPI Workflow (Server → React Client)
121189

122190
Harmonia uses SpringDoc to automatically generate an OpenAPI 3.0 specification, which is then used to generate a fully
@@ -163,12 +231,12 @@ and server in sync.
163231
- Merges Tailwind classes and resolves conflicts (e.g., `px-2` vs. `px-4`)
164232
- Needed for shadcn/ui components that combine base & conditional styles
165233
- **Example:**
166-
```ts
167-
const classes = twMerge(
168-
"px-4 py-2 text-sm text-gray-500", // base styles
169-
isActive && "text-blue-600 font-bold" // conditional styles
170-
);
171-
```
234+
```ts
235+
const classes = twMerge(
236+
"px-4 py-2 text-sm text-gray-500", // base styles
237+
isActive && "text-blue-600 font-bold" // conditional styles
238+
);
239+
```
172240

173241
#### `clsx`
174242

build.gradle

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ dependencies {
101101
// needed to reduce the number of vulnerabilities, also see https://mvnrepository.com/artifact/org.yaml/snakeyaml
102102
}
103103
}
104+
// H2 in-memory database for OpenAPI generation and testing
105+
runtimeOnly 'com.h2database:h2'
104106

105107
annotationProcessor 'org.projectlombok:lombok'
106108
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
@@ -116,7 +118,59 @@ dependencies {
116118
}
117119

118120
tasks.named('test') {
119-
useJUnitPlatform()
121+
useJUnitPlatform {
122+
// Exclude integration and e2e tests from regular test runs
123+
// These require external services (LM Studio, Artemis, etc.)
124+
excludeTags 'integration', 'e2e'
125+
}
126+
}
127+
128+
// Integration test task - requires external services
129+
// Run with: ./gradlew integrationTest
130+
// Automatically loads credentials from src/test/resources/test-credentials.properties
131+
tasks.register('integrationTest', Test) {
132+
description = 'Runs integration tests that require external services (LM Studio, Artemis, DB)'
133+
group = 'verification'
134+
135+
useJUnitPlatform {
136+
includeTags 'integration', 'e2e'
137+
}
138+
139+
// Explicitly set the test classes and classpath
140+
testClassesDirs = sourceSets.test.output.classesDirs
141+
classpath = sourceSets.test.runtimeClasspath
142+
143+
// Show standard output logs in the console
144+
testLogging {
145+
showStandardStreams = true
146+
events "passed", "skipped", "failed"
147+
}
148+
149+
shouldRunAfter tasks.named('test')
150+
151+
// Load credentials from properties file if it exists
152+
def credentialsFile = file('src/test/resources/test-credentials.properties')
153+
if (credentialsFile.exists()) {
154+
def props = new Properties()
155+
credentialsFile.withInputStream { stream ->
156+
props.load(stream)
157+
}
158+
// Set all properties as environment variables
159+
props.forEach { key, value ->
160+
environment key.toString(), value.toString()
161+
}
162+
}
163+
164+
// Pass through system environment variables (override file if set)
165+
if (System.getenv('ARTEMIS_TEST_URL')) environment 'ARTEMIS_TEST_URL', System.getenv('ARTEMIS_TEST_URL')
166+
if (System.getenv('ARTEMIS_TEST_USERNAME')) environment 'ARTEMIS_TEST_USERNAME', System.getenv('ARTEMIS_TEST_USERNAME')
167+
if (System.getenv('ARTEMIS_TEST_PASSWORD')) environment 'ARTEMIS_TEST_PASSWORD', System.getenv('ARTEMIS_TEST_PASSWORD')
168+
if (System.getenv('ARTEMIS_TEST_COURSE')) environment 'ARTEMIS_TEST_COURSE', System.getenv('ARTEMIS_TEST_COURSE')
169+
if (System.getenv('ARTEMIS_TEST_EXERCISE_ID')) environment 'ARTEMIS_TEST_EXERCISE_ID', System.getenv('ARTEMIS_TEST_EXERCISE_ID')
170+
if (System.getenv('ARTEMIS_TEST_MAX_TEAMS')) environment 'ARTEMIS_TEST_MAX_TEAMS', System.getenv('ARTEMIS_TEST_MAX_TEAMS')
171+
172+
// Always enable LLM tests for this task
173+
environment 'LLM_INTEGRATION_TESTS', 'true'
120174
}
121175

122176
// Available commands:

docker/local-setup/docker-compose.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ services:
3232
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/harmonia
3333
SPRING_DATASOURCE_USERNAME: postgres
3434
SPRING_DATASOURCE_PASSWORD: harmonia
35+
# Override AI base URL to point to host machine
36+
SPRING_AI_OPENAI_BASE_URL: http://host.docker.internal:1234
37+
extra_hosts:
38+
- "host.docker.internal:host-gateway"
3539
ports:
3640
- "8080:8080"
3741
healthcheck:

docker/nginx.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ http {
8282
add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains; preload' always;
8383
add_header X-Frame-Options "SAMEORIGIN" always;
8484

85-
# Proxy API requests to backend server
85+
# Proxy API requests to server
8686
location /api/ {
8787
proxy_http_version 1.1;
8888
proxy_set_header Upgrade $http_upgrade;
@@ -96,7 +96,7 @@ http {
9696
proxy_pass http://harmonia_server/api/;
9797
}
9898

99-
# Proxy actuator requests to backend server
99+
# Proxy actuator requests to server
100100
location /actuator/ {
101101
proxy_http_version 1.1;
102102
proxy_set_header Host $host;

0 commit comments

Comments
 (0)