Skip to content

feat: setup domain core db communication#16

Merged
MaximilianAnzinger merged 29 commits into
mainfrom
feature/setup-domain-core-db-communication
Dec 22, 2025
Merged

feat: setup domain core db communication#16
MaximilianAnzinger merged 29 commits into
mainfrom
feature/setup-domain-core-db-communication

Conversation

@vtotalova

@vtotalova vtotalova commented Dec 10, 2025

Copy link
Copy Markdown
Contributor

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

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

Architecture

  • Implemented layered architecture: Client Side → Server Actions → Services → Repository Interface → Repository Implementation → Prisma → Database
  • Created domain entities and input types for all models (User, Competency, LearningResource, CompetencyRelationship, CompetencyResourceLink)
  • Established repository pattern with interfaces and Prisma implementations
  • Added service layer for business logic and validation

Database

  • Updated Prisma schema to fix CompetencyResourceLink inconsistencies
  • Merged db-setup branch with schema and migration updates

Server

  • Domain Layer (lib/domain/domain_core.ts): Pure entities and input types for all models
  • Repository Interfaces (lib/repositories/dc_interface.ts): Contracts for User, Competency, LearningResource, CompetencyRelationship, CompetencyResourceLink repositories
  • Repository Implementation (lib/repositories/dc_user_repo.ts): Prisma implementations for all repositories (ONLY layer that touches database)
  • Services (lib/services/):
    • user-service.ts - User business logic
    • competency-service.ts - Competency business logic
    • learning-resource-service.ts - Learning resource business logic with URL uniqueness validation
    • competency-relationship-service.ts - Relationship business logic with self-reference validation
    • competency-resource-link-service.ts - Resource link business logic
  • Server Actions (app/actions/):
    • users.ts - User CRUD operations
    • competencies.ts - Competency CRUD operations
    • learning-resources.ts - Learning resource CRUD operations
    • competency-relationships.ts - Relationship CRUD operations
    • competency-resource-links.ts - Resource link CRUD operations

Documentation

  • Created DOMAIN_CORE.md with architecture overview, usage examples for Client Side (Server Components and Client Components), API integration guide, and rules

Testing

Test Cases

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

Manual Testing

  • Tested in development environment
  • Verified Prisma Client generation
  • Verified all layers properly connected
  • Tested with Prisma Studio for database visualization

Architecture Benefits

  • SQL Injection Protection: Prisma uses parameterized queries throughout
  • Type Safety: End-to-end TypeScript type safety from Client Side to database
  • Testability: Repository interfaces enable easy mocking for unit tests
  • Separation of Concerns: Clear boundaries between presentation, business logic, and data access
  • Maintainability: Changes to database layer don't affect business logic or Client Side code

Next Steps

Developers can now:

  • Use existing Server Actions from Client Side components
  • Expose services through Next.js API routes for external APIs
  • Follow the established pattern to add new entities (see existing implementations as reference)

vtotalova and others added 21 commits November 25, 2025 12:50
- 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>
@vtotalova vtotalova added this to the v0.1.0 milestone Dec 10, 2025
@vtotalova vtotalova self-assigned this Dec 10, 2025
Copilot AI review requested due to automatic review settings December 10, 2025 14:27
@vtotalova vtotalova added documentation Improvements or additions to documentation enhancement New feature or request labels Dec 10, 2025
@vtotalova vtotalova linked an issue Dec 10, 2025 that may be closed by this pull request
@vtotalova vtotalova added the database 🗃️ Database related changes label Dec 10, 2025
@github-actions

Copy link
Copy Markdown

🔍 Code Quality Report

📊 Code Statistics

🚨 Potential Issues

⚠️ Found console statements - consider removing for production
⚠️ Found 'any' or 'unknown' types - consider using more specific types

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

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.

Comment thread app/actions/competencies.ts Outdated
Comment thread app/actions/competency_relationships.ts
Comment thread DOMAIN_CORE.md Outdated
Comment thread lib/client/run-migrations.ts
Comment thread app/actions/competency_resource_links.ts Outdated
Comment thread app/actions/learning_resources.ts Outdated
Comment thread DOMAIN_CORE.md Outdated
Comment thread DOMAIN_CORE.md Outdated
Comment thread DOMAIN_CORE.md Outdated
Comment thread app/actions/users.ts
@github-actions

Copy link
Copy Markdown

🔍 Code Quality Report

📊 Code Statistics

🚨 Potential Issues

⚠️ Found console statements - consider removing for production
⚠️ Found 'any' or 'unknown' types - consider using more specific types

@github-actions github-actions Bot removed docker 🐳 Docker/deployment changes configuration ⚙️ Configuration file changes dependencies 📦 Dependency updates labels Dec 10, 2025
@github-actions github-actions Bot added the docker 🐳 Docker/deployment changes label Dec 10, 2025
@github-actions

Copy link
Copy Markdown

🔍 Code Quality Report

📊 Code Statistics

🚨 Potential Issues

⚠️ Found console statements - consider removing for production
⚠️ Found 'any' or 'unknown' types - consider using more specific types

Comment thread DOMAIN_CORE.md Outdated
Comment thread DOMAIN_CORE.md Outdated
Comment thread DOMAIN_CORE.md Outdated
Comment thread DOMAIN_CORE.md Outdated
Comment thread DOMAIN_CORE.md Outdated
Comment thread domain_core/infrastructure/run-migrations.ts
Comment thread lib/repositories/dc_repo.ts Outdated
Comment thread domain_core/services/competency.ts
Comment thread domain_core/services/competency_relationship.ts
Comment thread domain_core/services/competency_resource_link.ts
@github-actions

Copy link
Copy Markdown

🔍 Code Quality Report

📊 Code Statistics

🚨 Potential Issues

⚠️ Found console statements - consider removing for production
⚠️ Found 'any' or 'unknown' types - consider using more specific types

@github-actions github-actions Bot added the dependencies 📦 Dependency updates label Dec 15, 2025
@github-actions

Copy link
Copy Markdown

🔍 Code Quality Report

📊 Code Statistics

🚨 Potential Issues

⚠️ Found console statements - consider removing for production
⚠️ 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

@ls1intum ls1intum deleted a comment from Copilot AI Dec 16, 2025
@ls1intum ls1intum deleted a comment from Copilot AI Dec 16, 2025
@markstockhausen

markstockhausen commented Dec 17, 2025

Copy link
Copy Markdown
Contributor

Ready to merge (after @MaximilianAnzinger's approval)

@MaximilianAnzinger
MaximilianAnzinger merged commit 8ff1d3a into main Dec 22, 2025
10 checks passed
@MaximilianAnzinger
MaximilianAnzinger deleted the feature/setup-domain-core-db-communication branch December 22, 2025 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client-application 🎨 Client-side/UI changes database 🗃️ Database related changes dependencies 📦 Dependency updates docker 🐳 Docker/deployment changes documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: setup domain core (db communication)

4 participants