BeatSync is a Go backend service for saving, retrieving, and analyzing user heart rate data, with a focus on Heart Rate Variability (HRV) analytics. The service provides RESTful APIs for user management and heart data operations, leverages InfluxDB for time-series storage, and is fully containerized for easy deployment.
- User Management: Register, login, logout, update profile, and delete users with JWT-based authentication.
- Heart Rate Data: Store and retrieve heart rate and PPG sensor data per user/device.
- HRV Analysis: Analyze heart rate variability with metrics like SDNN, RMSSD, LF/HF ratio, and more.
- API Documentation: Interactive Swagger docs auto-generated from code annotations.
- Dockerized: Runs with Docker Compose, including InfluxDB as the backing store.
- Language: Go (Gin framework)
- Database: InfluxDB (time-series)
- API: RESTful, documented with Swagger
- Structure:
api/– API entrypoint, handlers, middlewaremodels/– Data models for users, HRV, authstorage/– InfluxDB integration and storage logicconfig/– Configuration and environment managementcmd/– Application entrypoint (main.go)compose.yaml– Docker Compose for local/dev
- Go 1.20+
- Docker
- Docker Compose
- Clone the repo:
git clone https://github.com/Ramazon1227/BeatSync.git cd BeatSync - Configure environment:
- Copy
.env.exampleto.envand fill in required values (InfluxDB, JWT secret, etc).
- Copy
- Run with Docker Compose:
The API will be available at
docker-compose -f compose.yaml up --build
http://localhost:8080by default.
- Build binary:
make build - Run locally:
make run - Generate Swagger docs:
make swag-init
- Interactive docs available at
/swagger/index.htmlwhen the service is running. - Example endpoints:
POST /v1/auth/register– Register userPOST /v1/auth/login– Login and receive JWTGET /v1/profile/{user_id}– Get user profilePOST /v1/hrv/analyze– Analyze HRV data
See .env.example for all variables. Key settings:
INFLUX_URL,INFLUX_TOKEN,INFLUX_ORG,INFLUX_BUCKETSECRET_KEY(JWT)SERVICE_HOST,HTTP_PORT, etc.
- Use the Makefile for common tasks (build, run, Docker image management).
- PRs and issues welcome!
Apache 2.0
- API Support: support@swagger.io
- Project by Ramazon1227