This repository contains a Sensor API that collects data from sensors and performs various aggregations. The API is built using the Go language and the Gin framework.
- Generate the meta data for both sensors & sensor groups
- Collects data from sensors
- Performs aggregations on sensor data
- Built with Go and Gin framework
- PostgreSQL for data storage
- Docker Compose for local development and testing
- Includes Swagger documentation for API endpoints
- Redis for few aggregation endpoints
Before you begin, ensure you have the following installed:
-
Clone the repository:
git clone https://github.com/srik007/sensor-api.git cd sensor-api
-
Rename
env.example
to.env
file in the project root and configure the data:APP_ENV=local DB_HOST=postgres DB_DRIVER=postgres DB_USER=postgres DB_PASSWORD=postgres DB_NAME=testdb DB_PORT=5432 PORT=8080 REDIS_URL=redis:6379 NUMBER_OF_SENSORS=3
-
Build docker image for current go application using
docker build -t app:latest .
-
Use Docker Compose to set up the local environment:
docker-compose up
The API will be available at http://localhost:8080
Swagger documentation is available at http://localhost:8080/swagger/index.html
-
Use docker-compose.test.yml to spin up the containers
docker-compose -f docker-compose.test.yml up -d
-
Run the tests
go test