Implementation Plan: User Profile Endpoint
Issue: #184 - What’s your name?
Summary
Add a user profile API endpoint that returns the authenticated user’s information, specifically their name and basic profile data. This addresses the question “What’s your name?” by providing a way for the application to retrieve and display the current user’s identity information. The implementation will leverage the existing Clerk authentication system to extract user details from the JWT token.
Approach
-
Create new API route at
api/src/routes/user_profile.py- Add handler for
GET /api/user/profileendpoint - Extract user information from Clerk JWT token (name, email, user_id)
- Return structured user profile response
- Add handler for
-
Update OpenAPI specification in
api/openapi.yaml- Add new
/api/user/profilepath definition - Define UserProfile response schema
- Include authentication requirements
- Add new
-
Register route in
api/src/index.py- Import new user profile handler
- Add route mapping for
/api/user/profile
-
Add frontend API client method in
packages/web/src/api/client.ts- Create
getUserProfile()method - Add TypeScript interface for user profile response
- Create
-
Update authentication middleware (if needed)
- Ensure user profile extraction from JWT includes name fields
- Verify existing
verify_user_tokenhandles name claims correctly
-
Add basic tests
- Unit test for user profile endpoint
- Ensure proper error handling for unauthenticated requests
Layers
backend, api, frontend
- Backend: New Python route handler and authentication logic
- API: New endpoint definition and OpenAPI spec updates
- Frontend: API client method to consume the new endpoint
Risks
- JWT token configuration - Clerk JWT template may not include name claims by default, requiring configuration changes
- Name field variations - Different authentication providers may use different claim names (firstName/lastName vs name vs displayName)
- Privacy considerations - Need to ensure we only return necessary user information, not sensitive data
- Rate limiting - Profile endpoint could be called frequently, may need caching or rate limits
Open Questions
- What specific user information should be returned? (full name, email, avatar, etc.)
- Should we cache user profile data or fetch fresh from Clerk on each request?
- Do we need to handle different name formats from various OAuth providers?
- Should this endpoint be public (for displaying user info) or require special permissions?
- Is there a preferred location in the UI to eventually display the user’s name?
Notes
- Existing
/api/companiesendpoint shows the pattern for JWT authentication and email extraction - Frontend already has Clerk
SignedIn/SignedOutcomponents for auth state management - Consider this as foundation for future user profile features (settings, preferences, etc.)