Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Coding Exercise

Setup, Build and Run with Docker Compose

docker compose build
docker compose up -d

API

  • GET /api/v1/user → [{ id, email, first_name, last_name, avatar }]

  • GET /api/v1/user/{id} → { id, email, first_name, last_name, avatar }

Features

  • if user attempts to reach an undefined route, they are redirected back to /user route
  • @tanstack/react-query library which enables optimistic ui, cache management, app state management & retrial
  • fail fast if web user is trying to reach a page for a non-integer user id (avoid children render + api call to backend)
  • lazy load user info component - only loads on demand and once passing basic validation like the user id format
  • runtime model validation with Zod happens during data fetch within tanstack useQuery hook, fail fast if validation fails before rendering
  • Reduced attack surface via minimal allowed priviledges: backend restricts allowed http methods (only GET) and origins
  • Backwards API compatibility via route versioning
  • environment variables handled via .env files with only necessary variables accessible in client environment

Future directions

  • specify retry delay + retrial logic in tanstack
  • infer typescript User type from the model defined by Zod (centralize, more representative of runtime, avoid drift)
  • Better UI - either Material UI/styled components or other libraries with modern look
  • ideally git commit for each functionality for easier version tracking/feature implementation
  • restrict response type and check content before using
  • UX features like navigation, search etc
  • Pagination, right now backend is only fetching/returning 5 users to avoid performance issue
  • Increase modularity - ie have Loading components in two places - separate out and reuse, similar can be done for user component
  • Access/permission implementation either via JWT, API key or IdP, can also extend further to endpoint-specific access controls
  • Use secret managers instead of storing api credentials in .env files
  • Add data validation with pydantic
  • Add observability: logging, tracing, auditing
  • Add testing: unit, integration, contract + e2e

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages