Implement product docs backend API (Stories 1 & 2)#6
Draft
Eric-Flecher-Glean wants to merge 4 commits intomainfrom
Draft
Implement product docs backend API (Stories 1 & 2)#6Eric-Flecher-Glean wants to merge 4 commits intomainfrom
Eric-Flecher-Glean wants to merge 4 commits intomainfrom
Conversation
This commit implements the first two stories from the technical implementation plan for a test-driven product documentation listing site: Story 1: Data Layer & Service Logic - Created static JSON data store (docs-data/docs.json) with Medtronic product documentation metadata - Implemented TypeScript type definitions (Doc interface) - Built document service with filtering and search capabilities: - getAllDocs(): Returns all documents sorted by order then title - findDocById(id): Retrieves single document by ID - filterDocs(query): Filters by search query and/or category - Added comprehensive unit tests (11 tests, all passing) Story 2: Express REST API - Implemented Express API endpoints: - GET /api/docs - List all docs with optional filtering via query params - GET /api/docs/:id - Get single document by ID - Added CORS support for frontend integration - Created integration tests using Supertest (8 tests, all passing) - Separated app definition from server bootstrap for testability Test Results: - All 19 tests passing (11 service + 8 API tests) - Test coverage includes: - Document sorting and retrieval - Case-insensitive filtering by category - Search query filtering across title, tags, and metadata - Combined filter logic (AND operation) - HTTP status codes and error handling Project Structure: - docs-data/docs.json - Product documentation metadata - backend/src/types/Doc.ts - TypeScript interface - backend/src/services/docsService.ts - Data access layer - backend/src/routes/docs.ts - Express routes - backend/src/index.ts - Express app setup - backend/src/server.ts - HTTP server bootstrap - backend/test/ - Unit and integration tests - backend/package.json - Dependencies and scripts Generated by Glean Code Writer
This commit implements Story 3 from the implementation plan: a complete React frontend with components and comprehensive tests. Frontend Implementation: - React + TypeScript + Vite setup with proper configuration - Component architecture: - FiltersBar: Search input and category dropdown for filtering - DocCard: Individual document display with PDF link - DocsList: Renders list of DocCard or empty state message - App: Main component with API integration and state management - API integration: - Fetches docs from /api/docs on mount - Filters by search query and category via URL params - Vite proxy configured to backend at http://localhost:4000 - Styling: Inline styles with clean, modern UI Test Implementation: - Vitest + React Testing Library setup - Component tests: - FiltersBar.test.tsx (4 tests): User interactions, callbacks - DocsList.test.tsx (4 tests): Rendering logic, empty state - App.test.tsx (7 tests): Mocked fetch, API integration, filtering - All 15 tests passing Test Results: ✅ FiltersBar: 4/4 tests passing ✅ DocsList: 4/4 tests passing ✅ App: 7/7 tests passing ✅ Total: 15/15 tests passing Files Added: - frontend/package.json - Dependencies and scripts - frontend/vite.config.ts - Vite config with API proxy - frontend/src/App.tsx - Main app component - frontend/src/main.tsx - Entry point - frontend/src/components/*.tsx - React components - frontend/src/tests/*.test.tsx - Component tests - frontend/src/types/Doc.ts - TypeScript interface - Configuration: tsconfig.json, .gitignore, index.html How to Run: cd demo/product-docs-site/frontend npm install npm test # Run all tests npm run dev # Start dev server on http://localhost:5173 Full Stack Demo Now Complete: - Backend API: Node.js + Express + Jest (19 tests passing) - Frontend: React + Vite + Vitest (15 tests passing) - Total: 34 tests passing across the stack Generated by Glean Code Writer
Generated by Glean Code Writer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR implements the first two stories from the technical implementation plan for a test-driven product documentation listing site.
Story 1: Data Layer & Service Logic ✅
docs-data/docs.json) with Medtronic product documentation metadata (8 products across 5 categories)Docinterface)docsService.ts) with data access and filtering:getAllDocs()- returns all documents sorted by order then titlefindDocById(id)- retrieves single document by IDfilterDocs(query)- filters by search query and/or category (case-insensitive)Story 2: Express REST API ✅
GET /api/docs- list all docs with optional filtering via query params (?q=search&category=Micra)GET /api/docs/:id- get single document by ID (returns 404 if not found)Files Added
demo/product-docs-site/README.md- Documentation for the projectdemo/product-docs-site/docs-data/docs.json- Product metadata (8 documents)demo/product-docs-site/backend/- Complete TypeScript backend with Node.js + Expresssrc/types/Doc.ts- Shared TypeScript interfacesrc/services/docsService.ts- Data access layer (60 lines)src/routes/docs.ts- Express routes (20 lines)src/index.ts- Express app setup (10 lines)src/server.ts- HTTP server bootstrap (10 lines)test/docsService.test.ts- Service unit tests (120 lines, 11 tests)test/docsRoutes.test.ts- API integration tests (100 lines, 8 tests)package.json,tsconfig.json,jest.config.cjs,.gitignoreTesting
Test Results
All 19 tests passing (ran via
npm testindemo/product-docs-site/backend/):Test Coverage
✅ Service layer unit tests (11 tests):
✅ API route integration tests (8 tests):
GET /api/docsreturns 200 and array of documents?q=Micra)?category=Micra)?q=technical&category=Micra)GET /api/docs/:idreturns 200 for valid IDGET /api/docs/:idreturns 404 for invalid IDManual Testing
Backend server can be started with:
API examples:
🤖 Generated by Glean Code Writer
📝 Chat link - https://app.glean.com/chat/593ef5f3e218438cbe47bec1b99745f9