feat: setup domain core db communication#16
Conversation
- Add unique constraint on CompetencyRelationship to prevent duplicates - Add database indexes on CompetencyResourceLink foreign keys for performance - Make userId optional in CompetencyResourceLink with SetNull on delete - Add error logging and visibility in migration system - Move database docs to root as DATABASE.md - Sync package-lock.json with package.json (TypeScript 5.9.3) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Co-authored-by: Maximilian Anzinger <44003963+MaximilianAnzinger@users.noreply.github.com>
Co-authored-by: Maximilian Anzinger <44003963+MaximilianAnzinger@users.noreply.github.com>
🔍 Code Quality Report📊 Code Statistics🚨 Potential Issues
|
There was a problem hiding this comment.
Pull request overview
This pull request establishes a comprehensive domain core architecture for database communication using Prisma ORM and the repository pattern. The implementation provides a clean, layered approach with proper separation of concerns between the presentation layer, business logic, and data access.
Key changes:
- Added Prisma ORM with PostgreSQL support, including schema definition and initial migration
- Implemented complete repository pattern with interfaces and Prisma implementations for all domain entities
- Created service layer with business logic and validation for Users, Competencies, Learning Resources, and their relationships
- Added server actions to expose CRUD operations to the client side
- Reorganized utility files and updated component imports
- Provided comprehensive documentation (DOMAIN_CORE.md, DATABASE.md)
Reviewed changes
Copilot reviewed 35 out of 38 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
prisma/schema.prisma |
Database schema defining 5 models with relationships and enums |
prisma/migrations/ |
Initial database migration and lock file |
lib/domain/domain_core.ts |
Pure domain entities and input types for all models |
lib/repositories/dc_interface.ts |
Repository interface contracts for data access |
lib/repositories/dc_repo.ts |
Prisma repository implementations (only layer touching database) |
lib/services/*.ts |
Business logic services for each domain entity |
lib/client/prisma.ts |
Prisma client singleton configuration with dev/prod logging |
lib/client/run-migrations.ts |
Runtime migration execution with environment-specific error handling |
lib/client/utils.ts |
Utility functions moved from lib/utils.ts |
app/actions/*.ts |
Server actions exposing CRUD operations for all entities |
instrumentation.ts |
Next.js instrumentation hook for automatic migration execution |
components/ui/*.tsx |
Updated imports to reference new utils location |
DOMAIN_CORE.md |
Architecture documentation with usage examples |
DATABASE.md |
Database setup and migration guide |
package.json |
Added Prisma dependencies and database management scripts |
Dockerfile |
Updated to support Prisma in production with schema and migrations |
docker/staging/docker-compose.yml |
Environment variable adjustments for staging |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
🔍 Code Quality Report📊 Code Statistics🚨 Potential Issues
|
…om:ls1intum/memo into feature/setup-domain-core-db-communication
🔍 Code Quality Report📊 Code Statistics🚨 Potential Issues
|
🔍 Code Quality Report📊 Code Statistics🚨 Potential Issues
|
🔍 Code Quality Report📊 Code Statistics🚨 Potential Issues
|
🔍 Code Quality Report📊 Code Statistics🚨 Potential Issues✅ No console statements found |
|
Ready to merge (after @MaximilianAnzinger's approval) |
Description
Implemented a complete domain core architecture for database communication following the repository pattern. This establishes a layered approach where only the domain core (repository layer) communicates directly with the database, ensuring proper separation of concerns and maintainability.
Type of Change
Related Issues
Changes Made
Architecture
Database
Server
lib/domain/domain_core.ts): Pure entities and input types for all modelslib/repositories/dc_interface.ts): Contracts for User, Competency, LearningResource, CompetencyRelationship, CompetencyResourceLink repositorieslib/repositories/dc_user_repo.ts): Prisma implementations for all repositories (ONLY layer that touches database)lib/services/):user-service.ts- User business logiccompetency-service.ts- Competency business logiclearning-resource-service.ts- Learning resource business logic with URL uniqueness validationcompetency-relationship-service.ts- Relationship business logic with self-reference validationcompetency-resource-link-service.ts- Resource link business logicapp/actions/):users.ts- User CRUD operationscompetencies.ts- Competency CRUD operationslearning-resources.ts- Learning resource CRUD operationscompetency-relationships.ts- Relationship CRUD operationscompetency-resource-links.ts- Resource link CRUD operationsDocumentation
DOMAIN_CORE.mdwith architecture overview, usage examples for Client Side (Server Components and Client Components), API integration guide, and rulesTesting
Test Cases
Manual Testing
Architecture Benefits
Next Steps
Developers can now: