This repository contains the Flatfile implementation for Comfort Systems USA, designed to streamline data import, validation, and processing for payroll and benefits information.
This implementation provides a customized Flatfile environment for importing various CSV files related to employee data. It includes data validation, transformation, and federation to create clean, structured datasets for downstream use.
Key features include:
- Custom Theming: The Flatfile space is themed to match the Comfort Systems USA branding.
- Data Validation: SSN validation and normalization are performed on the incoming data.
- Smart Import: An AI-powered canvas experience guides users through the data mapping process.
- Data Federation: Raw data is transformed and split into multiple "federated" views for different payroll types (Default, Extras, Prevailing Wages, Walker).
- Webhook Submission: Processed data can be submitted to a webhook for further integration.
- Node.js
- npm
- Flatfile CLI
- Clone this repository.
- Install the dependencies:
npm install
Before running the application, ensure you have the following environment variables set in your .env file:
FLATFILE_API_KEY: Your Flatfile API keyFLATFILE_ENVIRONMENT_ID: Your Flatfile environment IDWEBHOOK_SITE_URL: The webhook URL for data submission
Example .env file:
FLATFILE_API_KEY=your_api_key_here
FLATFILE_ENVIRONMENT_ID=your_environment_id_here
WEBHOOK_SITE_URL=https://webhook.site/your-unique-url
To run the Flatfile listener locally for development and testing, use the following command:
npx flatfile@latest developThis will start a local development server that connects to your Flatfile environment and listens for events. The development server will automatically reload when you make changes to your code.
To run a specific demo configuration, use:
npm run dev <demo-name>For example:
npm run dev comfort-systemsThe recommended deployment method is to use Flatfile's Agent service, which provides a secure, managed environment for your listeners.
npx flatfile@latest deploynpx flatfile@latest deploy -s comfort-systems-usaDeployment can also be handled through various platforms like Heroku, AWS, or any service that can run a Node.js application. The general steps are:
- Push the code to your chosen hosting provider.
- Ensure that all environment variables (e.g.,
WEBHOOK_SITE_URL,FLATFILE_API_KEY,FLATFILE_ENVIRONMENT_ID) are configured in the deployment environment. - Start the application.
This directory contains the core source code for the Flatfile implementation.
The main entry point for the Flatfile listener. It registers all the necessary plugins and listeners.
This directory contains the various listeners that react to events in the Flatfile ecosystem.
configure-space.listener.ts: Configures the Flatfile space with custom themes and metadata. It sets up thecompanyWorkbook.users-hook.listener.ts: Contains theallDataHook, which validates and normalizes SSNs and sets default location values.file-actions.listener.ts: Adds a "CSUSA Smart Import" action to newly created files.smart-import.listener.ts: Handles the "CSUSA Smart Import" action, creating a canvas experience for users to map their data to theAll Datasheet.federated.listener.ts: Implements the data federation logic, transforming data from theData Load Workbookinto theData Federationworkbook with multiple sheets.submit.listener.ts: Handles the submission of data from a workbook to a pre-configured webhook URL.
This directory defines the structure of the data within Flatfile, including sheets, workbooks, and actions.
-
src/blueprints/actions/:submit.action.ts: Defines the "Submit" action that can be applied to workbooks.
-
src/blueprints/sheets/:all-data.sheet.ts: A comprehensive "master" sheet that contains all possible fields from the various payroll and benefits CSV files.users.sheet.ts: A simple sheet for user information.federated/: This directory contains the definitions for the federated sheets, which are views created from theall-datasheet.default.federated.ts: Sheet for default payroll data.extras.federated.ts: Sheet for "extras" payroll data.prevailing-wages.federated.ts: Sheet for prevailing wage data.walker.federated.ts: Sheet for "Walker" specific payroll data.
-
src/blueprints/workbooks/:company.workbook.ts: Defines the main "Data Load Workbook" which uses theallDataSheet. This is the primary workbook for data import.federated.workbook.ts: Defines the "Data Federation" workbook, which contains all the federated sheets.
This directory contains example functions and helper utilities that support the main application logic but are not part of the core implementation.