{"id":31647942,"url":"https://github.com/masterfermin02/user-management","last_synced_at":"2026-07-15T16:33:15.278Z","repository":{"id":314761457,"uuid":"1056668712","full_name":"masterfermin02/user-management","owner":"masterfermin02","description":null,"archived":false,"fork":false,"pushed_at":"2025-10-02T16:08:14.000Z","size":260,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-10T23:34:35.939Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/masterfermin02.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-14T15:11:33.000Z","updated_at":"2025-10-02T16:08:18.000Z","dependencies_parsed_at":"2025-09-14T17:25:45.683Z","dependency_job_id":"f801e2de-9b6d-4af1-97c0-aa43a0562c68","html_url":"https://github.com/masterfermin02/user-management","commit_stats":null,"previous_names":["masterfermin02/user-management"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/masterfermin02/user-management","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masterfermin02%2Fuser-management","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masterfermin02%2Fuser-management/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masterfermin02%2Fuser-management/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masterfermin02%2Fuser-management/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/masterfermin02","download_url":"https://codeload.github.com/masterfermin02/user-management/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masterfermin02%2Fuser-management/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35513409,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-15T02:00:06.706Z","response_time":131,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-07T06:46:59.665Z","updated_at":"2026-07-15T16:33:15.272Z","avatar_url":"https://github.com/masterfermin02.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# User Endpoints — Firebase + React\n\n\u003e Take-home challenge implementation showing Firebase expertise, clean architecture, and React integration.\n\n---\n\n## 📌 Overview\n\nThis project implements user CRUD functionality using **Firebase Realtime Database** and **Firebase Cloud Functions**, with a **React (Vite)** front end.  \n\nThe key idea: **don’t rebuild what Firebase already provides.**\n\n- **Reads** use the Realtime Database SDK directly → instant, live updates.\n- **Writes/Updates/Deletes** go through Cloud Functions → enrich data securely (ZIP → Lat/Lon + Timezone) while hiding API keys.\n\nThis keeps the solution lean, efficient, and Firebase-native.\n\n---\n\n## 🏗️ Architecture\n\n```mermaid\nflowchart LR\n    A[React Frontend] -- Firebase SDK --\u003e B[Realtime Database]\n    A -- HTTP Fetch --\u003e C[Cloud Functions API]\n    C -- Admin SDK --\u003e B\n    C -- External API --\u003e D[OpenWeather]\n```\n\n- Realtime Database → stores user records.\n- Cloud Functions (Express app) → handles POST/PATCH/DELETE, enriches with OpenWeather + tz-lookup.\n- React Frontend → subscribes to users (real-time) and calls Functions for mutations.\n\n## Data Model\n\n```json\n/users/{id} {\n  \"id\": \"abc123\",\n  \"name\": \"Alice\",\n  \"zip\": \"10001\",\n  \"lat\": 40.75,\n  \"lon\": -73.99,\n  \"timezone\": \"America/New_York\",\n  \"tzOffsetSec\": -14400,\n  \"createdAt\": 1736720000000,\n  \"updatedAt\": 1736720500000\n}\n\n```\n\n- id: RTDB push key (unique, ordered, collision-resistant)\n- timezone: IANA timezone (DST-aware, reliable)\n- tzOffsetSec: UTC offset from OpenWeather (convenient for quick math)\n\n## Endpoints (Cloud Functions)\n\nBase URL:\n\n```bash\nhttps://us-central1-\u003cproject-id\u003e.cloudfunctions.net/api\n```\n\n| Method | Path         | Body Example                          | Notes                                |\n| ------ | ------------ | ------------------------------------- | ------------------------------------ |\n| POST   | `/users`     | `{ \"name\": \"Alice\", \"zip\": \"10001\" }` | Creates + enriches user              |\n| PATCH  | `/users/:id` | `{ \"zip\": \"94105\" }`                  | Updates; re-fetch geo if zip changed |\n| DELETE | `/users/:id` | –                                     | Deletes user                         |\n| GET    | `/users/:id` | –                                     | Optional detail fetch (mostly demo)  |\n\nReads (list, realtime) → done client-side with Firebase SDK. No redundant endpoint.\n\n## Setup\n\n1. Clone \u0026 install\n\n```bash\ngit clone https://github.com/yourname/user-endpoints-firebase.git\ncd user-endpoints-firebase\nnpm install\n```\n\n2. Firebase setup\n\n- Create Firebase project\n- Enable Realtime Database\n- Enable Cloud Functions\n\n3. Configure secrets\n\n```bash\ncd functions\ntouch .env.local\n```\n\nadd the OPENWEATHER_API_KEY\n\n4. Frontend config\n\nCreate web/.env.local:\n\n```bash\nVITE_FB_API_KEY=...\nVITE_FB_AUTH_DOMAIN=...\nVITE_FB_DB_URL=https://\u003cproject-id\u003e-default-rtdb.firebaseio.com\nVITE_FB_PROJECT_ID=...\nVITE_FB_APP_ID=...\nVITE_FUNCTIONS_BASE=https://us-central1-\u003cproject-id\u003e.cloudfunctions.net/api\n```\n\n5. Run locally (emulators)\n\n```bash\n# In one terminal\ncd functions\nnpm run serve\n```\n\n```bash\n# In another (frontend)\ncd web-app\nnpm run dev\n```\n\n6. Deploy\n\n```bash\nfirebase deploy --only functions,hosting\n```\n\n# Run testing\n\n```bash\n# In one terminal\ncd functions\nnpm run test\n```\n\n\n## What’s implemented\n\n- CRUD where it adds value (writes/updates/deletes on functions)\n- Real-time list in React via Firebase SDK\n- Zip → lat/lon + IANA timezone + UTC offset from OpenWeather\n- Input validation (Zod), CORS, errors surfaced cleanly\n- Demo-safe rules blocking client writes\n\n## Assumptions\n\n- Country defaults to US for ZIP resolution; easy to extend (accept country param).\n- We keep both IANA timezone and OpenWeather’s timezone offset seconds.\n- No auth for the take-home; add Firebase Auth + rules for prod.\n\n## Tests (what I spot-checked)\n\n- ZIP change triggers re-enrichment (lat/lon/timezone updated).\n- Invalid ZIP surfaces 400 with OpenWeather message.\n- Deleting removes record and client list updates instantly.\n- Emulator flow (Functions + RTDB) works end-to-end.\n\n## Trade-offs\n\n- Pros: fewer endpoints, lower latency, native realtime, least code; secrets stay server-side.\n- Cons: list reads happen client-side (not via REST). If you strictly require REST for reads, add GET /users—but you lose real-time unless you stream.\n\nWhy IANA tz: offsets alone aren’t stable (DST). IANA lets the client format times correctly year-round.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasterfermin02%2Fuser-management","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmasterfermin02%2Fuser-management","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasterfermin02%2Fuser-management/lists"}