|
| 1 | +# Modernization TODO List |
| 2 | + |
| 3 | +This document outlines the steps needed to modernize the analysis-tools.dev website by simplifying the backend and leveraging modern tools: **Algolia + InstantSearch + Headless UI + Static JSON/CMS**. |
| 4 | + |
| 5 | +## Current Architecture Overview |
| 6 | + |
| 7 | +The current setup has several layers of complexity: |
| 8 | +- Next.js with Server-Side Rendering (SSR) and API routes |
| 9 | +- Firebase/Firestore for votes storage |
| 10 | +- GitHub API for fetching tools data from external repos |
| 11 | +- File-based caching (`cache-manager-fs-hash`) |
| 12 | +- Custom search context and filtering logic |
| 13 | +- React Query for client-side data fetching |
| 14 | +- Docker deployment on Google Cloud Run via Pulumi |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +## Phase 1: Data Layer Modernization |
| 19 | + |
| 20 | +### 1.1 Static JSON Data Source |
| 21 | +- [x] Create a build-time script to fetch and consolidate `tools.json` from both `static-analysis` and `dynamic-analysis` repos |
| 22 | +- [x] Store consolidated data in `data/tools.json` at build time |
| 23 | +- [x] Remove runtime GitHub API calls (`utils-api/tools.ts` → `getTools()`) - New utilities in `utils/tools.ts`, `utils/static-data.ts` |
| 24 | +- [ ] Remove Octokit dependency (`@octokit/core`) - Keep for now, old code still present |
| 25 | +- [ ] Remove file-based cache (`cache-manager`, `cache-manager-fs-hash`) - Keep for now, old code still present |
| 26 | +- [ ] Delete `utils-api/cache.ts` - Keep for now, will remove in cleanup phase |
| 27 | + |
| 28 | +### 1.2 Votes Data Migration |
| 29 | +- [ ] **Option A**: Migrate votes to Algolia as a field in the tools index |
| 30 | +- [ ] **Option B**: Use a lightweight service (e.g., Supabase, PlanetScale) for votes |
| 31 | +- [x] **Option C**: Keep Firebase but simplify to client-side only voting - Implemented `utils/firebase-votes.ts` |
| 32 | +- [ ] Remove server-side Firebase Admin SDK (`firebase-admin`) - Still needed for votes |
| 33 | +- [ ] Delete `firebase-key.json` and related credentials handling - Still needed |
| 34 | +- [ ] Remove `utils-api/firebase.ts` - Keep for now, will remove in cleanup phase |
| 35 | +- [ ] Remove `utils-api/votes.ts` server-side logic - Keep for now, API routes still use it |
| 36 | +- [x] Simplify or remove `utils-api/toolsWithVotes.ts` - New `utils/tools-with-votes.ts` created |
| 37 | + |
| 38 | +### 1.3 Remove API Routes |
| 39 | +- [ ] Delete `pages/api/tools.ts` - Keep for now, tools page still uses it |
| 40 | +- [ ] Delete `pages/api/paginated-tools.ts` - Keep for now, tools page still uses it |
| 41 | +- [ ] Delete `pages/api/tags/*` - Keep for now |
| 42 | +- [ ] Delete `pages/api/vote/*` - Keep for now, voting still works via API |
| 43 | +- [ ] Delete `pages/api/votes/*` - Keep for now |
| 44 | +- [ ] Delete `pages/api/mostViewed.ts` - Keep for now |
| 45 | +- [ ] Delete `pages/api/popularLanguages.ts` - Keep for now |
| 46 | +- [ ] Delete `pages/api/articles.ts` (if not needed) - Keep for now |
| 47 | +- [ ] Remove entire `utils-api/` directory (migrate necessary utils to `utils/`) - Partially done |
| 48 | + |
| 49 | +### 1.4 New Static Data Utilities (Phase 1 Additions) |
| 50 | +- [x] Created `scripts/build-data.ts` - Build-time data fetching script |
| 51 | +- [x] Created `utils/static-data.ts` - Static data reader utility |
| 52 | +- [x] Created `utils/tools.ts` - Simplified tools utility |
| 53 | +- [x] Created `utils/tools-with-votes.ts` - Tools with votes merger |
| 54 | +- [x] Created `utils/firebase-votes.ts` - Simplified Firebase votes utility |
| 55 | +- [x] Created `utils/tags.ts` - Simplified tags utility |
| 56 | +- [x] Created `utils/filters.ts` - Filtering utility (moved from utils-api) |
| 57 | +- [x] Created `utils/stats.ts` - Stats utility for views data |
| 58 | +- [x] Updated `package.json` with `build-data` script and `prebuild` hook |
| 59 | +- [x] Updated `.gitignore` to exclude generated data files |
| 60 | +- [x] Updated `Dockerfile` to use new build process |
| 61 | +- [x] Updated `.github/workflows/deploy.yml` to use generated data for hashing |
| 62 | +- [x] Updated `pages/index.tsx` to use new static data utilities |
| 63 | +- [x] Updated `pages/tool/[slug].tsx` to use new static data utilities |
| 64 | +- [x] Updated `pages/tag/[slug].tsx` to use new static data utilities |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | +## Phase 2: Search & Filtering with Algolia + InstantSearch |
| 69 | + |
| 70 | +### 2.1 Algolia Index Enhancement |
| 71 | +- [ ] Enhance `algolia-index.ts` to run at build time (not from deployed API) |
| 72 | +- [ ] Add all filterable attributes to Algolia index: |
| 73 | + - `languages` (facet) |
| 74 | + - `categories` (facet) |
| 75 | + - `types` (facet) |
| 76 | + - `licenses` (facet) |
| 77 | + - `pricing`/`plans` (facet) |
| 78 | + - `votes` (for sorting) |
| 79 | + - `deprecated` (filter) |
| 80 | +- [ ] Configure Algolia dashboard: |
| 81 | + - Set up facets for filtering |
| 82 | + - Configure searchable attributes ranking |
| 83 | + - Set up sorting indices (by votes, by name, etc.) |
| 84 | + |
| 85 | +### 2.2 InstantSearch Integration |
| 86 | +- [ ] Upgrade `react-instantsearch` to latest version |
| 87 | +- [ ] Replace custom `SearchProvider` (`context/SearchProvider.tsx`) with InstantSearch provider |
| 88 | +- [ ] Delete `context/SearchProvider.tsx` |
| 89 | +- [ ] Replace `utils-api/filters.ts` logic with Algolia facets |
| 90 | +- [ ] Create new InstantSearch widgets: |
| 91 | + - [ ] `SearchBox` component |
| 92 | + - [ ] `RefinementList` for language filters |
| 93 | + - [ ] `RefinementList` for category filters |
| 94 | + - [ ] `RefinementList` for type filters |
| 95 | + - [ ] `RefinementList` for license filters |
| 96 | + - [ ] `RefinementList` for pricing filters |
| 97 | + - [ ] `SortBy` component for sorting |
| 98 | + - [ ] `Hits` component for results |
| 99 | + - [ ] `Pagination` or `InfiniteHits` component |
| 100 | + |
| 101 | +### 2.3 Replace Custom Data Fetching |
| 102 | +- [ ] Remove React Query (`@tanstack/react-query`) for tools fetching |
| 103 | +- [ ] Delete `components/tools/queries/tools.ts` |
| 104 | +- [ ] Delete `components/tools/queries/languages.ts` |
| 105 | +- [ ] Delete `components/tools/queries/others.ts` |
| 106 | +- [ ] Delete `components/tools/queries/index.ts` |
| 107 | +- [ ] Keep React Query only if needed for non-search data (blog posts, etc.) |
| 108 | + |
| 109 | +--- |
| 110 | + |
| 111 | +## Phase 3: UI Modernization with Headless UI |
| 112 | + |
| 113 | +### 3.1 Replace Custom UI Components |
| 114 | +- [ ] Install `@headlessui/react` |
| 115 | +- [ ] Replace custom dropdown (`components/elements/Dropdown`) with Headless UI `Listbox` |
| 116 | +- [ ] Replace mobile filters drawer with Headless UI `Dialog` |
| 117 | +- [ ] Create accessible filter components using Headless UI: |
| 118 | + - [ ] `Disclosure` for collapsible filter sections |
| 119 | + - [ ] `Combobox` for searchable language selector |
| 120 | + - [ ] `Switch` for toggle filters (e.g., "Show deprecated") |
| 121 | + - [ ] `Popover` for filter tooltips/info |
| 122 | + |
| 123 | +### 3.2 Component Cleanup |
| 124 | +- [ ] Audit and simplify `components/elements/` |
| 125 | +- [ ] Remove unused components |
| 126 | +- [ ] Standardize component patterns with Headless UI |
| 127 | + |
| 128 | +--- |
| 129 | + |
| 130 | +## Phase 4: Page Architecture Simplification |
| 131 | + |
| 132 | +### 4.1 Convert SSR Pages to Static (SSG) |
| 133 | +- [ ] Convert `pages/tools/index.tsx` from `getServerSideProps` to `getStaticProps` |
| 134 | +- [ ] All filtering/search handled client-side via InstantSearch |
| 135 | +- [ ] Keep `pages/tool/[slug].tsx` as static (`getStaticProps` + `getStaticPaths`) ✓ (already done) |
| 136 | +- [ ] Keep `pages/tag/[slug].tsx` as static ✓ (already done) |
| 137 | +- [ ] Consider Incremental Static Regeneration (ISR) for data freshness |
| 138 | + |
| 139 | +### 4.2 Simplify Page Components |
| 140 | +- [ ] Refactor `ListPageComponent.tsx` to use InstantSearch |
| 141 | +- [ ] Remove infinite scroll complexity (use Algolia pagination) |
| 142 | +- [ ] Remove `useRouterPush` hook for search state (InstantSearch handles URL) |
| 143 | +- [ ] Delete `hooks/` directory if no longer needed |
| 144 | + |
| 145 | +### 4.3 Data Flow Cleanup |
| 146 | +- [ ] Remove `utils/query.ts` (objectToQueryString) |
| 147 | +- [ ] Remove `utils/urls.ts` if only used for API URLs |
| 148 | +- [ ] Simplify `utils/constants.ts` |
| 149 | + |
| 150 | +--- |
| 151 | + |
| 152 | +## Phase 5: Build & Deployment Simplification |
| 153 | + |
| 154 | +### 5.1 Build Process |
| 155 | +- [ ] Create `scripts/build-data.ts`: |
| 156 | + - Fetch tools from GitHub repos |
| 157 | + - Fetch star history (optional, can be removed) |
| 158 | + - Merge and validate data |
| 159 | + - Output to `data/tools.json` |
| 160 | + - Update Algolia index |
| 161 | +- [ ] Update `package.json` scripts: |
| 162 | + ```json |
| 163 | + { |
| 164 | + "prebuild": "npm run build-data", |
| 165 | + "build-data": "ts-node scripts/build-data.ts", |
| 166 | + "build": "next build" |
| 167 | + } |
| 168 | + ``` |
| 169 | +- [ ] Remove runtime data fetching from build process |
| 170 | + |
| 171 | +### 5.2 Environment Variables Cleanup |
| 172 | +- [ ] Remove `GOOGLE_APPLICATION_CREDENTIALS` |
| 173 | +- [ ] Remove `GH_TOKEN` (if data is fetched at build time from public repos) |
| 174 | +- [ ] Keep only: |
| 175 | + - `ALGOLIA_APP_ID` |
| 176 | + - `ALGOLIA_API_KEY` (search-only key for client) |
| 177 | + - `ALGOLIA_ADMIN_KEY` (for indexing, build-time only) |
| 178 | + - `PUBLIC_HOST` |
| 179 | + |
| 180 | +### 5.3 Docker & Deployment |
| 181 | +- [ ] Simplify `Dockerfile` (no credentials needed at runtime) |
| 182 | +- [ ] Consider static export (`next export`) if no server features needed |
| 183 | +- [ ] Evaluate moving from Cloud Run to static hosting (Vercel, Netlify, Cloudflare Pages) |
| 184 | +- [ ] Simplify or remove Pulumi infrastructure if using static hosting |
| 185 | +- [ ] Update `.github/workflows/deploy.yml` |
| 186 | + |
| 187 | +--- |
| 188 | + |
| 189 | +## Phase 6: CMS Integration (Optional) |
| 190 | + |
| 191 | +### 6.1 Content Management |
| 192 | +- [ ] Evaluate CMS options for non-tool content: |
| 193 | + - Blog posts (currently markdown in `data/blog/`) |
| 194 | + - FAQ content (`data/faq.json`) |
| 195 | + - Sponsors (`data/sponsors.json`) |
| 196 | + - Homepage content (`data/homepage.json`) |
| 197 | +- [ ] Consider headless CMS options: |
| 198 | + - Contentlayer (for markdown) |
| 199 | + - Sanity |
| 200 | + - Strapi |
| 201 | + - Directus |
| 202 | +- [ ] Or keep as static JSON/Markdown if editorial workflow is simple |
| 203 | + |
| 204 | +--- |
| 205 | + |
| 206 | +## Phase 7: Dependency Cleanup |
| 207 | + |
| 208 | +### 7.1 Remove Unused Dependencies |
| 209 | +```json |
| 210 | +{ |
| 211 | + "remove": [ |
| 212 | + "@octokit/core", |
| 213 | + "cache-manager", |
| 214 | + "cache-manager-fs-hash", |
| 215 | + "firebase-admin", |
| 216 | + "algoliasearch-helper", |
| 217 | + "@tanstack/react-query" |
| 218 | + ], |
| 219 | + "keep": [ |
| 220 | + "algoliasearch", |
| 221 | + "react-instantsearch", |
| 222 | + "next", |
| 223 | + "react", |
| 224 | + "react-dom" |
| 225 | + ], |
| 226 | + "add": [ |
| 227 | + "@headlessui/react" |
| 228 | + ] |
| 229 | +} |
| 230 | +``` |
| 231 | + |
| 232 | +### 7.2 DevDependencies Cleanup |
| 233 | +- [ ] Remove unused type definitions |
| 234 | +- [ ] Update ESLint config for simplified codebase |
| 235 | +- [ ] Consider switching to Biome or similar for faster linting |
| 236 | + |
| 237 | +--- |
| 238 | + |
| 239 | +## Phase 8: Code Quality & Maintenance |
| 240 | + |
| 241 | +### 8.1 TypeScript Improvements |
| 242 | +- [ ] Remove all `@ts-nocheck` and `@ts-ignore` comments |
| 243 | +- [ ] Fix type errors in `context/SearchProvider.tsx` (before deletion) |
| 244 | +- [ ] Ensure strict TypeScript throughout |
| 245 | + |
| 246 | +### 8.2 Testing |
| 247 | +- [ ] Add unit tests for data transformation utilities |
| 248 | +- [ ] Add integration tests for search functionality |
| 249 | +- [ ] Add E2E tests for critical user flows |
| 250 | + |
| 251 | +### 8.3 Documentation |
| 252 | +- [ ] Update `README.md` with new architecture |
| 253 | +- [ ] Document new build process |
| 254 | +- [ ] Document Algolia configuration |
| 255 | +- [ ] Create contributing guide for the simplified codebase |
| 256 | + |
| 257 | +--- |
| 258 | + |
| 259 | +## Migration Checklist Summary |
| 260 | + |
| 261 | +### Files to Delete |
| 262 | +- [ ] `utils-api/` (entire directory) |
| 263 | +- [ ] `pages/api/` (entire directory) |
| 264 | +- [ ] `context/SearchProvider.tsx` |
| 265 | +- [ ] `components/tools/queries/` (entire directory) |
| 266 | +- [ ] `firebase-key.json` |
| 267 | +- [ ] `algolia-index.js` (keep only `.ts` version) |
| 268 | + |
| 269 | +### Files to Create |
| 270 | +- [ ] `scripts/build-data.ts` |
| 271 | +- [ ] `components/search/SearchProvider.tsx` (InstantSearch wrapper) |
| 272 | +- [ ] `components/search/SearchBox.tsx` |
| 273 | +- [ ] `components/search/Filters.tsx` |
| 274 | +- [ ] `components/search/Results.tsx` |
| 275 | +- [ ] `components/ui/` (Headless UI wrappers) |
| 276 | + |
| 277 | +### Files to Significantly Modify |
| 278 | +- [ ] `pages/tools/index.tsx` |
| 279 | +- [ ] `pages/index.tsx` |
| 280 | +- [ ] `components/tools/listPage/ListPageComponent/ListPageComponent.tsx` |
| 281 | +- [ ] `next.config.js` |
| 282 | +- [ ] `package.json` |
| 283 | +- [ ] `.github/workflows/deploy.yml` |
| 284 | +- [ ] `Dockerfile` |
| 285 | + |
| 286 | +--- |
| 287 | + |
| 288 | +## Benefits After Modernization |
| 289 | + |
| 290 | +1. **Simpler Architecture**: No server-side API routes, no runtime data fetching |
| 291 | +2. **Better Performance**: Static pages with client-side search (instant) |
| 292 | +3. **Lower Costs**: Static hosting is cheaper than Cloud Run |
| 293 | +4. **Better DX**: Less code to maintain, clearer data flow |
| 294 | +5. **Better Search UX**: Algolia InstantSearch provides superior search experience |
| 295 | +6. **Accessibility**: Headless UI components are accessible by default |
| 296 | +7. **Scalability**: Algolia handles search at any scale |
| 297 | +8. **Reliability**: Fewer moving parts = fewer things to break |
0 commit comments