Skip to content

[ResourceApp][Backend][Feat] Implement group membership endpoints#74

Merged
sthanikan2000 merged 3 commits intoLSFLK:mainfrom
saknarajapakshe:71-feat-usergroup-endpoints
Mar 24, 2026
Merged

[ResourceApp][Backend][Feat] Implement group membership endpoints#74
sthanikan2000 merged 3 commits intoLSFLK:mainfrom
saknarajapakshe:71-feat-usergroup-endpoints

Conversation

@saknarajapakshe
Copy link
Copy Markdown
Contributor

@saknarajapakshe saknarajapakshe commented Mar 20, 2026

Overview

This PR completes the Group Membership implementation for the Resource bounded context. It adds full DDD-style flow for /api/groups/:id/users endpoints (GET/POST/DELETE) and enforces atomic DB operations with explicit transactions in repository methods.

  • GET /api/groups/:id/users
  • POST /api/groups/:id/users
  • DELETE /api/groups/:id/users/:userId

What changed

  • cmd/server/main.go: route registration for group membership
  • internal/group/handlers.go: handlers + validation + status mapping
  • internal/group/services.go: service methods
  • internal/group/repository.go: repository methods with transactions (atomic operations)

Transactions

  • POST /groups/:id/users: one transaction → verify group + users + no existing mapping → insert membership rows
  • DELETE /groups/:id/users/:userId: one transaction delete membership row (in user_groups table) with check

How to test locally

  1. ensure database is ready (MySQL and resource_app DB).
  2. apply migrations
  3. run tests:
    go test ./...
  4. run server:
    go run ./cmd/server/main.go
  5. Test endpoints
    GET /api/groups/:groupId/users
    POST /api/groups/:groupId/users
    DELETE /api/groups/:groupId/users/:userId

image image image

realated to #71
closes #78

@saknarajapakshe saknarajapakshe requested a review from a team March 20, 2026 06:52
@saknarajapakshe saknarajapakshe marked this pull request as draft March 20, 2026 06:53
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the Resource application's backend by completing the group membership functionality within the Resource bounded context. It establishes a robust, DDD-style architecture for managing groups and their associated users, ensuring that all interactions are handled with proper validation, error management, and transactional integrity.

Highlights

  • Group Membership Endpoints: Implemented full CRUD operations for groups and new endpoints for managing group memberships: GET /api/groups/:id/users, POST /api/groups/:id/users, and DELETE /api/groups/:id/users/:userId.
  • Atomic Database Operations: Ensured data integrity by enforcing atomic database operations with explicit GORM transactions in repository methods, particularly for adding and deleting group memberships.
  • New Group Module: Introduced a new 'group' module with dedicated handlers, services, repository, and models to manage group entities and their relationships with users.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new 'group' feature, including models, repository, service, and API handlers for managing groups and their user memberships. The changes involve adding new database tables (groups and user_groups), integrating them with GORM, and exposing a comprehensive set of REST API endpoints for group CRUD operations and membership management. Review comments suggest improvements such as enhancing security by not exposing raw error messages to clients, ensuring transactional integrity in the RemoveUserFromGroup method to prevent race conditions, adding a unique database constraint for user_groups to enforce data integrity, standardizing error messages for invalid IDs, refactoring anonymous request structs into named types for better maintainability, and correcting code style for struct field alignment.

@saknarajapakshe saknarajapakshe force-pushed the 71-feat-usergroup-endpoints branch from 18ca0a2 to b2a4f25 Compare March 20, 2026 09:21
@saknarajapakshe saknarajapakshe marked this pull request as ready for review March 23, 2026 04:32
@ginaxu1 ginaxu1 marked this pull request as draft March 23, 2026 09:01
@ginaxu1
Copy link
Copy Markdown

ginaxu1 commented Mar 23, 2026

in both #72 and here you are introducing changes in same branch 71-feat-usergroup-endpoints, so there are duplicate changes

please merge #72 first, then in this branch git rebase origin/main to update correctly

@ginaxu1 ginaxu1 marked this pull request as ready for review March 23, 2026 09:14
@saknarajapakshe saknarajapakshe force-pushed the 71-feat-usergroup-endpoints branch 4 times, most recently from 46ff968 to f164550 Compare March 24, 2026 07:12
@saknarajapakshe saknarajapakshe marked this pull request as draft March 24, 2026 08:31
@saknarajapakshe saknarajapakshe force-pushed the 71-feat-usergroup-endpoints branch from f164550 to 464c6a7 Compare March 24, 2026 11:25
@saknarajapakshe saknarajapakshe marked this pull request as ready for review March 24, 2026 11:26
@saknarajapakshe saknarajapakshe force-pushed the 71-feat-usergroup-endpoints branch from 464c6a7 to 8df9b1f Compare March 24, 2026 12:25
@sthanikan2000 sthanikan2000 merged commit d197f9a into LSFLK:main Mar 24, 2026
saknarajapakshe pushed a commit to saknarajapakshe/superapp-mobile-x that referenced this pull request Mar 24, 2026
…dpoints

[ResourceApp][Backend][Feat] Implement group membership endpoints
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.

[ResourceApp][Backend][Feat] - Group Domain Implement User-Group Membership Management

3 participants