A server application for ingesting and retrieving health data.
This repo is a rewrite-oriented descendant of the original project by the Health Auto Export app producer:
- Original upstream:
HealthyApps/health-auto-export-server - This repo:
nilswx/health-auto-export-server
It is not a shallow fork. The current architecture here is intentionally PostgreSQL + Hasura + Fastify/TypeScript, with custom proxy/OpenAPI behavior.
- PostgreSQL database for structured health data storage
- Hasura GraphQL Engine for advanced querying capabilities
- Hasura REST API for direct REST API access
- Fastify for fast and low overhead web server
- TypeScript for type safety and better development experience
- Docker for containerization and easy deployment
- Application Server API - Custom endpoints (available on port 3001 by default)
- Hasura GraphQL API - Proxied through the application server at
/graphql - Hasura REST API - Proxied through the application server at
/api/ - OpenAPI Documentation - Available at
/openapi.yaml
- Docker and Docker Compose
- Node.js 16+ (for local development)
- Clone the repository
- Start the development environment:
# Start in development mode with Hasura
npm run dev:all
# Or start individual services
npm run docker:up # Start PostgreSQL and Hasura
npm run dev # Start the Node.js server in dev modeIn production deployments, ingestion and read APIs should be protected with an
API_KEY secret and clients should send either:
api-key: <API_KEY>Authorization: Bearer <API_KEY>
For the iOS Health Auto Export app integration, set the header name to
api-key.
Hasura provides both GraphQL and REST APIs for your data:
Access the GraphQL API directly at:
http://localhost:8080/v1/graphql
Or through the application server proxy at:
http://localhost:3001/graphql
Automatically generated REST APIs are available through the application server proxy:
http://localhost:3001/api/{table_name}
http://localhost:3001/api/{table_name}/{id}
The application automatically generates OpenAPI documentation for all available REST endpoints:
http://localhost:3001/openapi.yaml
This can be viewed with tools like Swagger UI or Redoc.
This system uses a layered architecture:
- PostgreSQL for data storage
- Hasura for GraphQL and REST API generation
- Application server for custom endpoints and proxying
- Health data is ingested via the
/api/dataendpoint - Data is parsed and stored in the appropriate PostgreSQL tables
- When new tables are created, Hasura is automatically signaled to reload its schema definitions and create REST APIs
- Data can be retrieved via the proxied GraphQL API or REST API endpoints
src/- Source code for the application servercontrollers/- Request handlersdb/- Database connection and schema managementmodels/- Data models and typesplugins/- Fastify pluginsroutes/- API routesutils/- Utility functions
hasura/- Hasura configurationscripts/- Helper scripts
- POST /api/data - Main ingestion endpoint for health data
- GET /api/metrics/:selected_metric - Retrieve data for a specific metric
- GET /api/workouts - List all workouts
- GET /api/workouts/:id - Get details for a specific workout
- POST /admin/reload-services - Manually trigger service reloads for Hasura
- GET /openapi.yaml - Get the OpenAPI specification for all available APIs
- POST /graphql - GraphQL API proxy to Hasura
- GET/POST /api/* - REST API proxy to Hasura
To add new functionality:
- Create new controllers and routes in the appropriate directories
- Update the database schema if needed
- Register new routes in
src/index.ts
This project is licensed under the MIT License.
Contributions are welcome! Please feel free to submit a Pull Request.