Skip to content

add Recommendation Feedback Persistence with Supabase Storage#34

Merged
Adilislam0 merged 3 commits into
Life-Atlas:stagingfrom
yayyyyshi:yashika/recommendation-feedback
Jun 22, 2026
Merged

add Recommendation Feedback Persistence with Supabase Storage#34
Adilislam0 merged 3 commits into
Life-Atlas:stagingfrom
yayyyyshi:yashika/recommendation-feedback

Conversation

@yayyyyshi

Copy link
Copy Markdown
Collaborator

Overview

This PR completes the recommendation feedback persistence workflow for the LPI Recommendation Engine. Users can now record whether a recommendation was accepted or dismissed, and the feedback is securely stored in Supabase for future analysis and recommendation refinement.

The implementation introduces persistent feedback storage, request validation, authenticated ownership checks, database migration support, and test stability improvements while preserving the existing recommendation generation pipeline.


What was implemented

1. Recommendation Feedback Persistence

Implemented persistent storage for recommendation feedback instead of returning temporary in-memory responses.

Each feedback record stores:

  • Feedback ID
  • User ID
  • Recommendation ID
  • Recommended action
  • SMILE phase
  • Feedback status (accepted / dismissed)
  • Timestamp

2. Feedback API Endpoint

Completed the feedback endpoint:

POST /api/v1/recommendations/{user_id}/feedback

The endpoint now:

  • Validates authentication
  • Verifies ownership
  • Creates a RecommendationFeedback model
  • Persists the record to Supabase
  • Returns the stored object

3. Database Integration

Added Aryan's Supabase migration to create therecommendation_feedback table.

The persistence layer now inserts feedback directly into the database using the existing Supabase client.


4. Store Layer

Added a new storage helper:

insert_recommendation_feedback()

Responsibilities:

  • Accept RecommendationFeedback model
  • Serialize model
  • Insert into Supabase
  • Return stored object

5. Data Models

Extended the models with support for recommendation feedback.

Added:

  • RecommendationFeedback
  • RecommendationFeedbackCreate

These separate request payload validation from the persisted database object.


6. Recommendation Engine Integration

Updated the recommendation pipeline to support persistent feedback without affecting recommendation generation.

Recommendation IDs are now treated as first-class identifiers that can later be used for:

  • analytics
  • feedback history
  • ranking improvements
  • future recommendation learning

7. Authentication & Authorization

Implemented ownership validation before storing feedback.

Only the authenticated owner of a recommendation can submit feedback.

Requests from other users correctly return:

403 Forbidden

8. Database Migration

Added migration:

20260621000000_create_recommendation_feedback.sql

which creates the new feedback table required by the persistence layer.


9. Test Stability Improvement

Pytest execution was intermittently failing because the in-memory rate limiter accumulated request counts across tests.

Instead of modifying the rate limiter logic, the test environment now clears the in-memory rate limiter state before and after each test through the shared pytest fixtures.

This preserves production behavior while ensuring deterministic test execution.


Files Modified

  • src/lpi/models.py
  • src/lpi/store.py
  • src/lpi/routers/recommendations.py
  • src/lpi/recommendation_engine.py
  • tests/conftest.py
  • supabase/migrations/20260621000000_create_recommendation_feedback.sql

Testing

Executed the full project test suite.

pytest

Result:

164 passed

Additionally verified:

  • Recommendation feedback successfully stored in Supabase
  • Authorization checks
  • Invalid ownership returns 403
  • Database migration applied successfully
  • Existing recommendation endpoints unaffected
  • Full recommendation test suite continues to pass

Outcome

This PR completes the persistence layer for recommendation feedback, enabling recommendation decisions to be recorded permanently in Supabase while maintaining compatibility with the existing recommendation engine and ensuring full test suite stability.

@yayyyyshi yayyyyshi force-pushed the yashika/recommendation-feedback branch 2 times, most recently from cb53017 to d66adb6 Compare June 22, 2026 10:55
@yayyyyshi yayyyyshi force-pushed the yashika/recommendation-feedback branch from d66adb6 to 2e9e538 Compare June 22, 2026 10:57
@Adilislam0 Adilislam0 merged commit fb22214 into Life-Atlas:staging Jun 22, 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.

2 participants