Implement Phase 1: Backend API with TDD (Product Docs Website)#5
Open
Eric-Flecher-Glean wants to merge 2 commits intomainfrom
Open
Implement Phase 1: Backend API with TDD (Product Docs Website)#5Eric-Flecher-Glean wants to merge 2 commits intomainfrom
Eric-Flecher-Glean wants to merge 2 commits intomainfrom
Conversation
This commit adds a comprehensive test-driven development (TDD) implementation plan for a simple website that lists and provides access to Medtronic product documentation stored in Google Drive. The plan includes: - Complete technology stack (React, TypeScript, Vitest, Playwright) - Architecture overview with API integration for Google Drive - Data model for product documents - 10 TDD implementation phases covering: * Project setup and infrastructure * Google Drive API integration with tests * Document list, search, and filter components * Category navigation and document preview * Responsive design and accessibility * Performance optimization * E2E testing with Playwright * CI/CD pipeline with GitHub Actions - File structure and project organization - Security considerations and environment setup - Success metrics and future enhancements - 5-week estimated timeline Product documentation inventory analyzed from: https://drive.google.com/drive/folders/1KuN_YhLOk4KTdORa0rdpG24hLyd4kjfP Includes documentation for Micra leadless pacemakers (VR2, AV2), coronary products, and other cardiac devices. Generated by Glean Code Writer
This commit implements the first story of work from the implementation
plan: a fully test-driven Express.js backend API for serving Medtronic
product documentation metadata.
## What's Implemented
### Data Layer
- Created docs-data/docs.json with 12 product documents:
* 8 Micra leadless pacemaker documents (VR2, AV2, MC1AVR1)
* 1 Coronary product catalog
* 1 Symplicity Spyral hypertension treatment brochure
* 2 reference data files (CSV catalog, data dictionary)
### Backend API (Test-Driven Development)
- Express.js + TypeScript with strict mode
- RESTful API with two endpoints:
* GET /api/docs - List/filter all documents
* GET /api/docs/:id - Get single document by ID
- CORS enabled for frontend integration
- In-memory caching for performance
### Service Layer (src/services/docsService.ts)
- getAllDocs() - Returns sorted documents (by order, then title)
- findDocById() - Finds document by ID
- filterDocs() - Filters by category and/or search query
* Case-insensitive search
* Searches across title, category, product_family, tags
* AND logic for combined filters
### Test Coverage (TDD)
- 22 comprehensive tests covering:
* Service layer (docsService.test.ts)
- Document loading and caching
- Sorting algorithms
- Filter logic (category, search, combined)
- Edge cases (empty queries, non-existent IDs)
- Case-insensitive search
* API layer (docsRoutes.test.ts)
- HTTP status codes (200, 404)
- Query parameter handling
- Response structure validation
- CORS headers
- Error responses
### Configuration
- TypeScript strict mode (tsconfig.json)
- Jest test framework (jest.config.cjs)
- Package.json with dev/test/build scripts
- .gitignore for Node.js projects
### Documentation
- Main README with project overview
- Backend README with API documentation
- API endpoint examples with curl commands
- Development and testing instructions
## File Structure
```
demos/product-docs-website/
├── README.md # Main project documentation
├── docs-data/
│ └── docs.json # 12 product documents
└── backend/
├── README.md # Backend API documentation
├── package.json
├── tsconfig.json
├── jest.config.cjs
├── .gitignore
├── src/
│ ├── index.ts # Express app
│ ├── server.ts # HTTP server
│ ├── routes/
│ │ └── docs.ts # Document routes
│ ├── services/
│ │ └── docsService.ts # Data access layer
│ └── types/
│ └── Doc.ts # TypeScript interfaces
└── test/
├── docsService.test.ts # Service tests
└── docsRoutes.test.ts # API integration tests
```
## Testing
All tests pass:
- Service layer: 15 tests
- API layer: 7 tests
- Total: 22 tests
- Aiming for 80%+ coverage
## Next Steps
- Phase 2: Frontend implementation (React + Vite)
- Phase 3: E2E testing and deployment
## Related
- Implementation plan: demos/product-docs-website/IMPLEMENTATION_PLAN.md
- PR #4: Technical implementation plan
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 Phase 1: Backend API from the implementation plan, delivering a fully functional, test-driven Express.js API for serving Medtronic product documentation metadata.
What's Implemented
✅ Data Layer
Created
docs-data/docs.jsonwith 12 product documents:All document metadata includes:
✅ Backend API (Test-Driven Development)
Technology Stack:
API Endpoints:
GET /api/docsList all documents or filter by query parameters.
Query Parameters:
q- Search query (searches title, category, product_family, tags)category- Filter by exact category (case-insensitive)Examples:
GET /api/docs/:idGet a single document by ID.
Returns: Document object (200) or error (404)
✅ Service Layer
docsService.ts- Pure functions for data access:getAllDocs()- Returns all documents sorted by order, then titlefindDocById(id)- Finds document by IDfilterDocs(query)- Filters by category and/or search query✅ Comprehensive Test Coverage (TDD)
22 tests covering all functionality:
Service Tests (
docsService.test.ts- 15 tests):API Tests (
docsRoutes.test.ts- 7 tests):All tests pass with 80%+ coverage target
✅ Configuration Files
package.json- Dependencies and scripts (dev, test, build)tsconfig.json- Strict TypeScript configurationjest.config.cjs- Jest test framework setup.gitignore- Node.js best practices✅ Documentation
File Structure
Total: 14 new files, 1038 lines of code
Testing
How to Run Tests
Test Results
Test Examples
TDD Approach
This implementation strictly follows Test-Driven Development:
Example TDD flow:
docsService.test.tswith 15 test casesdocsService.tsto pass all testsdocsRoutes.test.tswith 7 integration testsroutes/docs.tsandindex.tsto pass testsNext Steps
Related PRs
🤖 Generated by Glean Code Writer
📝 Chat link - https://app.glean.com/chat/593ef5f3e218438cbe47bec1b99745f9