Skip to content

feat: add Review entity with session-based constraints#154

Merged
ahmadogo merged 1 commit intoMentoNest:mainfrom
mijinummi:feature/reviews-rbac
Jan 31, 2026
Merged

feat: add Review entity with session-based constraints#154
ahmadogo merged 1 commit intoMentoNest:mainfrom
mijinummi:feature/reviews-rbac

Conversation

@mijinummi
Copy link
Contributor

⭐ Implement Review Entity & Validation Rules

Context

To support structured feedback and mentor quality tracking, the platform requires a review system tightly coupled to completed mentoring sessions. Reviews must follow strict eligibility rules to preserve data integrity and prevent abuse.

This PR introduces a fully validated Review domain with API-level and database-level enforcement.


✨ What’s Included

🧱 Review Entity & Schema

  • New Review entity linked to:
    • Reviewer (mentee)
    • Reviewee (mentor)
    • Session
  • Rating constrained to 1–5
  • Optional textual comment
  • Database uniqueness enforced on (session, reviewer)
  • Indexed for efficient lookups

🔐 Business Rules Enforcement

  • Reviews allowed only after session completion
  • Reviewer must be the session mentee
  • Reviewee must be the session mentor
  • Duplicate reviews per session are prevented
  • All invalid attempts return clear, meaningful errors

🌐 API

  • POST /reviews endpoint to create a review
  • Authenticated and rule-protected
  • Reviewer identity derived from session context (not user input)

📊 Rating Aggregation (Optional Enhancement)

  • Mentor’s average rating recalculated after each new review
  • Lays groundwork for analytics, ranking, and reputation features

🧪 Test Coverage

  • Prevents review before session completion
  • Blocks non-mentee review attempts
  • Prevents duplicate reviews per session
  • Allows valid review for completed sessions
  • Ensures correct mentor assignment as reviewee

✅ Acceptance Criteria Checklist

  • Review entity and database schema implemented
  • API endpoint to create review
  • Reviews blocked before session completion
  • Reviewer verified as session mentee
  • Reviewee verified as session mentor
  • Duplicate reviews prevented (DB + service)
  • Proper error messages returned
  • Unit tests added for entity and rules
  • Optional mentor rating aggregation implemented

🔮 Future Extensions

This implementation supports future enhancements without refactor:

  • Review moderation
  • Review editing windows
  • Mentor responses
  • Advanced rating analytics

Notes for Reviewers

  • All rules are enforced at the service layer and backed by DB constraints
  • No breaking changes to existing session or user flows
  • Designed to scale with analytics and reputation systems
    Closes Review Entity & Rules #150

@ahmadogo ahmadogo merged commit fec1c9a into MentoNest:main Jan 31, 2026
0 of 2 checks 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.

Review Entity & Rules

2 participants