Skip to content

Refactor: Move internal/pkg modules to infrastructure layer#12

Merged
slhmy merged 2 commits intomainfrom
copilot/refactor-internalize-pkg-modules
Feb 3, 2026
Merged

Refactor: Move internal/pkg modules to infrastructure layer#12
slhmy merged 2 commits intomainfrom
copilot/refactor-internalize-pkg-modules

Conversation

Copy link
Contributor

Copilot AI commented Feb 3, 2026

Relocates legacy internal/pkg modules into internal/infrastructure with domain-specific organization for improved architectural clarity and maintainability.

Module Relocation

From To
internal/pkg/gormclient internal/infrastructure/persistence/gorm
internal/pkg/mongoclient internal/infrastructure/persistence/mongo
internal/pkg/redisclient internal/infrastructure/cache/redis
internal/pkg/smtpmailer internal/infrastructure/notification/smtp
internal/pkg/app internal/infrastructure/bootstrap
internal/pkg/grpcutils internal/infrastructure/bootstrap

Changes

  • Package declarations: Updated to match new directory structure (package gorm, package redis, etc.)
  • Import paths: Updated across all consuming code (cmd, application, infrastructure layers)
  • Directory cleanup: Removed internal/pkg entirely

Example

- import "github.com/poly-workshop/identra/internal/pkg/gormclient"
- import "github.com/poly-workshop/identra/internal/pkg/redisclient"
+ import "github.com/poly-workshop/identra/internal/infrastructure/persistence/gorm"
+ import "github.com/poly-workshop/identra/internal/infrastructure/cache/redis"

- db := gormclient.NewDB(cfg)
- rdb := redisclient.NewRDB(cfg)
+ db := gorm.NewDB(cfg)
+ rdb := redis.NewRDB(cfg)

This organization aligns infrastructure components by their architectural role rather than generic "pkg" grouping, making it clearer where to find and add similar functionality.

Original prompt

This section details on the original issue you should resolve

<issue_title>Refactor: Internalize pkg modules into infrastructure layer for better maintainability</issue_title>
<issue_description>## Summary

Currently, several modules under internal/pkg are legacy components migrated from external libraries and customized for Identra. To improve maintainability, architecture clarity, and alignment with DDD best practices, these packages should be fully internalized within the internal/infrastructure layer.

Proposal

  • Move all modules from internal/pkg into appropriate subfolders under internal/infrastructure, making their purpose and project ownership clear.
  • Update all import paths and configuration references throughout the codebase.
  • Adjust docs and development guides to reflect the new structure.

Proposed mapping:

Current Location Proposed Location
internal/pkg/gormclient internal/infrastructure/persistence/gorm
internal/pkg/mongoclient internal/infrastructure/persistence/mongo
internal/pkg/redisclient internal/infrastructure/cache/redis
internal/pkg/smtpmailer internal/infrastructure/notification/smtp
internal/pkg/app internal/infrastructure/bootstrap

Tasks

  • Move gormclient, mongoclient, redisclient, smtpmailer, app to infrastructure layer as above
  • Update all import paths accordingly
  • Update configuration loading to use new locations
  • Fix or adapt related unit/integration tests
  • Update documentation and diagrams as needed

Benefits

  • Unified infrastructure code organization
  • Clearer boundaries between project-specific and possible third-party code
  • Easier future refactoring/extension (e.g. alternative notification or storage implementations)
  • Less confusion for new contributors

Extra Notes

If any implementation is truly generic and intended for future external reuse, consider keeping those in a separate top-level pkg/ directory. Otherwise, internalizing all Identra-specific infrastructure makes maintenance simpler and the architecture clearer.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- Moved gormclient to internal/infrastructure/persistence/gorm
- Moved mongoclient to internal/infrastructure/persistence/mongo
- Moved redisclient to internal/infrastructure/cache/redis
- Moved smtpmailer to internal/infrastructure/notification/smtp
- Moved app to internal/infrastructure/bootstrap
- Moved grpcutils to internal/infrastructure/bootstrap
- Updated all import paths throughout the codebase
- Updated package declarations to match new locations
- All builds and tests pass successfully

Co-authored-by: slhmy <31381093+slhmy@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor pkg modules into infrastructure layer for maintainability Refactor: Move internal/pkg modules to infrastructure layer Feb 3, 2026
Copilot AI requested a review from slhmy February 3, 2026 13:55
@slhmy slhmy marked this pull request as ready for review February 3, 2026 13:58
@slhmy slhmy merged commit d960b9f into main Feb 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor: Internalize pkg modules into infrastructure layer for better maintainability

2 participants