User Personalization Features
Relevant source files
The following files were used as context for generating this wiki page:
User personalization in Actionmap centers on providing a tailored experience through secure authentication and the ability for users to interact with and rate content specific to political representatives. The system allows users to maintain a persistent profile, save preferences, and manage personal data such as news ratings and localized events.
The architecture relies on OmniAuth for external provider integration (Google and GitHub), an Active Record session store for persistence, and a relational database schema that links users to their specific ratings and news items.
Sources: app/controllers/login_controller.rb:1-83, db/schema.rb:76-85, config/application.rb:36-38
Authentication and Session Management
The personalization features are predicated on a robust authentication system. Actionmap utilizes OAuth 2.0 via Google and GitHub to identify users. The LoginController manages the lifecycle of a user session, from initial redirection to the provider to the creation or retrieval of a local user record.
Authentication Flow
The following sequence diagram illustrates the process of a user logging in via an external provider and the subsequent session creation within the application.
User Data Structure
The users table stores basic profile information derived from the authentication provider.
| Field | Type | Description |
|---|---|---|
provider | integer | The enum value for the auth provider (Google/GitHub) |
uid | string | Unique identifier from the provider |
email | string | User's email address |
first_name | string | User's first name |
last_name | string | User's last name |
Sources: db/schema.rb:76-85, app/controllers/login_controller.rb:50-77
Personal News and Article Ratings
A core personalization feature is the ability for users to search for news articles related to specific representatives and issues, and subsequently rate those articles. This data is persisted and linked directly to the authenticated user.
Article Rating Logic
When a user selects an article to rate, the MyNewsItemsController processes the request. If the user has already rated a specific article (identified by title, link, and description), the existing rating is updated; otherwise, a new rating record is created.
News Item Search Integration
Users can personalize their news feed by searching for keywords combining a representative's name and a specific issue. The system uses the News API to fetch the top 5 most popular articles, which are temporarily stored in the session before the user commits a rating.
Sources: app/controllers/my_news_items_controller.rb:19-31, app/controllers/my_news_items_controller.rb:102-110
Data Models for Personalization
The database schema defines the relationships necessary to support user-specific data.
Entity Relationship Diagram
The following diagram shows how users are connected to ratings and news items.
Sources: db/schema.rb:41-85
Personalized Routes and Endpoints
The application provides specific endpoints for users to manage their personal profile and viewed content.
| Endpoint | Method | Controller Action | Description |
|---|---|---|---|
/user/profile | GET | user#profile | Displays the logged-in user's profile information. |
/user/articles | GET | user#articles | Lists news articles rated or saved by the user. |
/my_events/new | GET/POST | my_events#new/create | Allows users to create personalized political events. |
/logout | GET | login#logout | Clears the session and logs the user out. |
Sources: config/routes.rb:11-25, app/controllers/login_controller.rb:18-21
Conclusion
User Personalization Features in Actionmap provide the bridge between general political data (representatives and counties) and individual user engagement. By leveraging OAuth for identity and maintaining a dedicated ratings system, the application enables users to curate their own experience and track their interactions with political news items.