Enhancement to an internal React Native inventory management application that tracks medical supplies as they are received and shipped. I developed a data export feature that allows users to export inventory table data directly to Google Sheets for reporting and analysis.
Built a serverless backend API that exports filtered inventory data from the MySQL database to Google Sheets, creating organized sheets for each box/group combination.
- Backend: Node.js, Express.js
- Database: MySQL
- APIs: Google Sheets API v4
- Authentication: Google Service Account (JWT)
- Deployment: AWS Lambda (serverless function)
- Dynamic sheet creation: Automatically creates new sheets with naming convention
Box{number}_Group{name} - Query-based filtering: Exports specific inventory data based on group name and box number
- Auto-formatting: Dynamically extracts column headers from database results and formats data for spreadsheet compatibility
- Implemented Google Sheets API integration using service account authentication
- Used connection pooling for efficient database queries
- Built parameterized SQL queries to prevent injection vulnerabilities
- Designed async/await pattern for improved error handling and response times
- Environment variable configuration for secure credential management
The feature operates as a serverless function that:
- Receives group name and box number as query parameters
- Queries MySQL database for matching inventory records
- Creates a new sheet in the target Google Spreadsheet
- Formats and appends data with headers to the new sheet
- Returns success response to the client
- Ensuring data integrity when jsonData could be undefined or empty
- Creating dynamic sheet names based on inventory metadata
- Handling async operations efficiently to prevent timeout issues on the client side