Skip to content

Implement core service layer and platform abstraction#4

Merged
bloboss merged 2 commits into
mainfrom
claude/document-gitlab-migration-bCjTb
Mar 28, 2026
Merged

Implement core service layer and platform abstraction#4
bloboss merged 2 commits into
mainfrom
claude/document-gitlab-migration-bCjTb

Conversation

@bloboss

@bloboss bloboss commented Mar 28, 2026

Copy link
Copy Markdown
Owner

Summary

This PR implements the core business logic layer and platform abstraction for Class Forge, enabling the API to interact with both Forgejo and GitLab instances. It includes complete service implementations for classrooms, assignments, teams, rosters, and submissions, along with their corresponding repository interfaces and PostgreSQL implementations.

Key Changes

  • Platform Abstraction Layer (internal/platform/)

    • Defined Provider interface with sub-interfaces for repositories, users, organizations, teams, and branches
    • Implemented Forgejo provider with support for direct repository collaborators
    • Implemented GitLab provider with group/project mapping
    • Added provider registry for dynamic provider instantiation
    • Defined platform-agnostic types (Repository, User, Organization, etc.)
  • Service Layer (internal/service/)

    • Implemented ClassroomService with create, list, get, update, delete, and archive operations
    • Implemented AssignmentService with full CRUD and statistics
    • Implemented TeamService for team management and member operations
    • Implemented RosterService for student roster management and linking
    • Implemented SubmissionService for tracking student submissions
    • All services include input validation and error handling
  • Repository Layer (internal/repository/)

    • Defined repository interfaces for classrooms, assignments, teams, rosters, and submissions
    • Implemented PostgreSQL-backed repositories with full CRUD operations
    • Added filtering and pagination support across all repositories
    • Implemented team member join table operations
  • Database Migrations

    • Created migrations for assignments, roster entries, teams, team members, and submissions tables
    • Added corresponding down migrations for rollback support
  • API Handler Updates

    • Updated classroom, assignment, team, roster, and submission handlers to use service layer
    • Integrated service dependencies into handler constructors
    • Added error handling utilities for service-layer errors
  • Configuration & Testing

    • Added GitLab configuration support to config system
    • Added platform type configuration option
    • Implemented comprehensive unit tests for services, repositories, and platform providers
    • Created mock implementations for testing
  • Documentation

    • Added comprehensive API reference documentation
    • Added getting started guide with installation and configuration instructions
    • Added configuration reference with examples for both Forgejo and GitLab
    • Updated README with feature list and architecture overview

Notable Implementation Details

  • Services use a validator utility for consistent input validation across the application
  • Platform providers are registered in a factory pattern for easy extensibility
  • Repository interfaces are designed to be mockable for testing
  • All database operations use context for cancellation support
  • Error handling uses sentinel errors from the platform package for type-safe error checking
  • Pagination is standardized across all list operations with configurable page size limits

https://claude.ai/code/session_017LmTi5pT5kjF4u3scesiDv

claude added 2 commits March 28, 2026 03:11
Introduce a platform-agnostic abstraction layer that allows class-forge
to target multiple git hosting backends (Forgejo and GitLab) through a
unified Provider interface. The existing Forgejo infrastructure is
preserved while adding GitLab as a new backend option.

Key changes:
- internal/platform: Core interfaces (Provider, RepositoryProvider,
  UserProvider, OrganizationProvider, TeamProvider, BranchProvider,
  CollaboratorProvider), shared types, sentinel errors, and a
  thread-safe provider registry/factory
- internal/platform/forgejo: Forgejo provider implementation skeleton
- internal/platform/gitlab: GitLab provider implementation skeleton
  with API mapping documentation (Groups=Orgs, Projects=Repos, etc.)
- internal/config: Add PlatformConfig.Type selector ("forgejo"|"gitlab"),
  GitLabConfig struct, and platform-aware validation
- internal/model: Rename Forgejo-specific fields to platform-agnostic
  names (ForgejoUsername -> PlatformUsername, ForgejoUserID ->
  PlatformUserID)
- internal/api: Rename integration error codes from FORGEJO-specific
  to PLATFORM-generic, update service name to "class-forge"

All 30 tests pass across platform, config, and model packages.

https://claude.ai/code/session_017LmTi5pT5kjF4u3scesiDv
Add complete repository layer (PostgreSQL), service layer (business logic),
database migrations, API handler wiring, and user-facing documentation
for classrooms, assignments, rosters, teams, and submissions.

- Database migrations (000002-000006) for all domain tables
- Repository interfaces and SQL implementations for all entities
- Service layer with validation, platform integration, and error handling
- API handlers wired to services with standardized error mapping
- User documentation: getting-started, configuration, API reference
- Unit tests for services, repositories, and platform abstraction
- Updated README to reflect multi-platform support (Forgejo + GitLab)

https://claude.ai/code/session_017LmTi5pT5kjF4u3scesiDv
@bloboss bloboss force-pushed the claude/document-gitlab-migration-bCjTb branch from 612c313 to c5f42ad Compare March 28, 2026 03:59
@bloboss bloboss merged commit 1f40329 into main Mar 28, 2026
2 checks passed
@bloboss bloboss deleted the claude/document-gitlab-migration-bCjTb branch March 28, 2026 04:01
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.

2 participants