Skip to content

feat: create relationship import system#45

Open
vtotalova wants to merge 72 commits into
mainfrom
feature/43-feat-create-relationship-import-system
Open

feat: create relationship import system#45
vtotalova wants to merge 72 commits into
mainfrom
feature/43-feat-create-relationship-import-system

Conversation

@vtotalova

Copy link
Copy Markdown
Contributor

Description

Implements a bulk import system for competency relationships, allowing admins to create multiple relationships at once from a JSON or CSV file. Relationships can be referenced by competency ID or title, with an optional seed vote on import.

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as
    expected)
  • 📝 Documentation update
  • 🎨 Style/formatting changes (no functional changes)
  • ♻️ Code refactoring (no functional changes)
  • ⚡ Performance improvements
  • 🔧 Configuration changes
  • 🧪 Test additions or modifications
  • 🚀 Deployment/DevOps changes

Related Issues

Changes Made

  • Client:
    • Added RelationshipImportPage at /admin/import/relationships with file upload (drag-and-drop) and JSON paste modes
    • Added importRelationshipsJson and importRelationshipsFile methods to adminApi
    • Added RelationshipImportRow interface to types.ts; fixed CompetencyRelationship.relationshipType union to include UNRELATED
    • Registered new route and added "Import Relationships" card to the Admin panel
  • Server:
    • Added RelationshipImportRow DTO supporting originId/originTitle, destinationId/destinationTitle, and optional relationshipType
    • Added bulkImportRelationships() to CompetencyRelationshipService with per-row validation, title-to-ID resolution, duplicate skipping, and optional vote seeding
    • Added findByTitle() to CompetencyRepository
    • Added POST /api/admin/relationships/import (JSON) and POST /api/admin/relationships/import/file (CSV/JSON) to AdminController with dynamic header-based CSV parsing
  • Database: No migrations required
  • Other: Added sample-data/relationships-sample.json and relationships-sample.csv for manual testing

Testing

Test Cases

  • Existing functionality still works
  • New functionality works as expected
  • Edge cases handled appropriately

Manual Testing

  • Tested in development environment
  • Tested with different user roles/permissions (if applicable)

Verified the following scenarios via the Import Relationships UI and the provided sample files:

  • ID-based rows — both competencies looked up by ID, relationship created
  • Title-based rows — both competencies resolved by exact title match
  • Mixed rows — one side by ID, other by title
  • With relationshipType — vote seeded on the corresponding counter, entropy recalculated
  • Without relationshipType — relationship created with zero votes
  • Duplicate pair — skipped and counted in skipped, not errors
  • Unknown title — per-row error returned in ImportResult.errors
  • Self-reference — per-row error returned
  • Invalid relationshipType — per-row error returned
  • CSV file upload — columns matched by header name (case-insensitive, order-independent)
  • JSON file upload — deserialized and processed identically to JSON paste
  • Admin-only access — endpoint returns 403 for non-admin users

Screenshots/Videos

Before

After

markstockhausen and others added 30 commits February 3, 2026 02:22
…sable component to use it on main page and while onboarding

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements an admin-facing bulk import workflow for competency relationships (CSV/JSON), alongside a broader shift to Keycloak-backed authentication/authorization and a new admin panel surface for moderation and role management.

Changes:

  • Added admin UI pages for moderation, importing competencies/relationships, role management, and export placeholder.
  • Introduced Keycloak auth integration on the client (AuthProvider, protected/admin routes, axios bearer token injection).
  • Added server-side admin import endpoints + import DTOs/results, plus /api/auth/me, JWT resource server config, and user schema updates for Keycloak UUID subjects.

Reviewed changes

Copilot reviewed 49 out of 51 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/pages/SessionPage.tsx Switches demo-user bootstrap to fetch current authenticated user.
src/pages/RolesPage.tsx New admin UI to view users and toggle roles.
src/pages/RelationshipImportPage.tsx New UI for relationship bulk import via file upload or JSON paste.
src/pages/OnboardingPage.tsx Integrates auth state into onboarding flow; persists some fields in sessionStorage; adds privacy-policy link.
src/pages/ModerationPage.tsx New admin UI for inline editing and deleting competencies/resources.
src/pages/ImportPage.tsx New UI for competency bulk import via file upload or JSON paste.
src/pages/HomePage.tsx Start button now navigates based on auth + onboarded status.
src/pages/ExportPage.tsx New “Export” placeholder page in admin area.
src/pages/DashboardPage.tsx Uses authenticated userId for stats instead of guest constant.
src/pages/AdminPage.tsx New admin panel landing page with cards to admin tools.
src/lib/auth/keycloak.ts Adds Keycloak client initialization (check-sso, PKCE, silent SSO).
src/lib/api/types.ts Adds ImportResult + RelationshipImportRow; expands relationshipType union with UNRELATED; adds degree to Competency.
src/lib/api/session-helpers.ts Adds /api/auth/me helper for retrieving current user.
src/lib/api/client.ts Adds axios request interceptor to attach Bearer token and refresh token when needed.
src/lib/api/admin.ts New admin API client for import endpoints (JSON + file).
src/index.css Extends CSS custom properties for theme colors.
src/contexts/useAuth.ts New hook for accessing AuthContext.
src/contexts/auth-context.ts Defines AuthContextValue and creates AuthContext.
src/contexts/AuthContext.tsx New AuthProvider that initializes Keycloak, syncs /api/auth/me, and exposes auth state/actions.
src/components/navbar.tsx Shows sign-in/out + admin link based on auth/role; updates gradient class usage.
src/components/ProtectedRoute.tsx New route guard requiring authentication (and handling domain denial).
src/components/AdminRoute.tsx New route guard requiring ADMIN role.
src/App.tsx Wraps app in AuthProvider; adds protected and admin route structure + new pages.
server/src/main/resources/db/migration/V9__update_users_for_keycloak_auth.sql Alters users table for Keycloak subjects and adjusts one FK column length.
server/src/main/resources/application.yml Configures OAuth2 resource server JWT, multipart limits, Flyway settings, and allowed email domain list.
server/src/main/java/de/tum/cit/memo/service/UserService.java Adds find-or-create by Keycloak subject.
server/src/main/java/de/tum/cit/memo/service/CompetencyService.java Adds bulk import logic for competencies with per-row validation/skip.
server/src/main/java/de/tum/cit/memo/service/CompetencyRelationshipService.java Adds bulk relationship import with title/id resolution, duplicate skipping, and optional vote seeding.
server/src/main/java/de/tum/cit/memo/security/SecurityConfig.java Switches API to JWT-authenticated resource server; restricts admin and delete routes.
server/src/main/java/de/tum/cit/memo/security/DbRoleJwtAuthenticationConverter.java Maps authorities from DB role keyed by JWT subject.
server/src/main/java/de/tum/cit/memo/repository/CompetencyRepository.java Adds existsByTitle and findByTitle.
server/src/main/java/de/tum/cit/memo/entity/User.java Makes name/email nullable and expands id length to 36.
server/src/main/java/de/tum/cit/memo/dto/RelationshipImportRow.java DTO for relationship import rows.
server/src/main/java/de/tum/cit/memo/dto/ImportResult.java Record for import result summary.
server/src/main/java/de/tum/cit/memo/dto/CompetencyImportRow.java DTO for competency import rows.
server/src/main/java/de/tum/cit/memo/controller/AuthController.java Adds /api/auth/me to enforce domain allowlist + sync user record.
server/src/main/java/de/tum/cit/memo/controller/AdminController.java Adds admin import endpoints for competencies and relationships; implements CSV/JSON parsing.
server/src/main/java/de/tum/cit/memo/config/MemoProperties.java Adds memo.allowed-email-domains config binding.
server/src/main/java/de/tum/cit/memo/MemoApiApplication.java Enables configuration properties scanning.
server/docker/keycloak/memo-realm.json Updates Keycloak realm config (protocol mapper for email; SMTP config; removes seeded users).
server/docker-compose.yml Adds Mailpit; configures Keycloak + API + DB containers; adjusts Keycloak issuer env.
server/build.gradle Adds Spring OAuth2 resource server dependency.
sample-data/relationships-sample.json Adds sample relationship import JSON.
sample-data/relationships-sample.csv Adds sample relationship import CSV.
sample-data/competencies-sample.json Adds sample competency import JSON.
sample-data/competencies-sample.csv Adds sample competency import CSV.
public/silent-check-sso.html Adds Keycloak silent SSO callback page.
postcss.config.mjs Removed config file (repo retains postcss.config.js).
package-lock.json Dependency lockfile updates.
auth-flow.svg Adds auth flow diagram (SVG).
auth-flow.mmd Adds auth flow diagram (Mermaid source).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread server/docker-compose.yml
Comment thread server/src/main/java/de/tum/cit/memo/controller/AdminController.java Outdated
Comment thread server/src/main/java/de/tum/cit/memo/controller/AdminController.java Outdated
Comment thread src/pages/ModerationPage.tsx Outdated
Comment thread src/pages/DashboardPage.tsx
Comment thread server/src/main/resources/application.yml Outdated
@github-actions github-actions Bot added enhancement New feature or request dependencies 📦 Dependency updates and removed client-application 🎨 Client-side/UI changes labels Apr 13, 2026
@github-actions

Copy link
Copy Markdown

🔍 Code Quality Report

📊 Code Statistics

🚨 Potential Issues

✅ No console statements found
⚠️ Found 'any' or 'unknown' types - consider using more specific types

@vtotalova vtotalova changed the title Feature/43 feat create relationship import system feat: create relationship import system Apr 13, 2026
@github-actions

Copy link
Copy Markdown

🔍 Code Quality Report

📊 Code Statistics

🚨 Potential Issues

✅ No console statements found
⚠️ Found 'any' or 'unknown' types - consider using more specific types

@github-actions

Copy link
Copy Markdown

🔍 Code Quality Report

📊 Code Statistics

🚨 Potential Issues

✅ No console statements found
⚠️ Found 'any' or 'unknown' types - consider using more specific types

@github-actions

Copy link
Copy Markdown

🔍 Code Quality Report

📊 Code Statistics

🚨 Potential Issues

✅ No console statements found
⚠️ Found 'any' or 'unknown' types - consider using more specific types

@MaximilianAnzinger MaximilianAnzinger left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please have a look at the merge conflict

@github-actions github-actions Bot removed the dependencies 📦 Dependency updates label Apr 24, 2026
@github-actions

Copy link
Copy Markdown

🔍 Code Quality Report

📊 Code Statistics

🚨 Potential Issues

✅ No console statements found
⚠️ Found 'any' or 'unknown' types - consider using more specific types

@github-actions

Copy link
Copy Markdown

🔍 Code Quality Report

📊 Code Statistics

🚨 Potential Issues

✅ No console statements found
⚠️ Found 'any' or 'unknown' types - consider using more specific types

@github-actions

Copy link
Copy Markdown

🔍 Code Quality Report

📊 Code Statistics

🚨 Potential Issues

✅ No console statements found
⚠️ Found 'any' or 'unknown' types - consider using more specific types

@github-actions github-actions Bot added the dependencies 📦 Dependency updates label Apr 26, 2026
@github-actions

Copy link
Copy Markdown

🔍 Code Quality Report

📊 Code Statistics

🚨 Potential Issues

✅ No console statements found
⚠️ Found 'any' or 'unknown' types - consider using more specific types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies 📦 Dependency updates enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: create relationship import system

4 participants