Take home task from fold.money REST API service that will query Elasticsearch.
Install postgres and logstash on local
Steps to start REST api service
-
Setup infra (Optional) // TODO : Pass config/secrets to env such as hostname,username and password
- run
terraform init
- run
terraform apply
# This will setup postgres in AWS and ES in ES cloud
- run
-
run
sh setup.sh
- This will create table schemas, triggers and functions which are required.
- And it will also create ES index in ES cloud
-
Setup and run logstash
- Download logstash
- Download jdbc driver library for postgre
- Copy scripts/logstash/jdbc.conf to logstash directory
- Update jdbc_driver_library field in jdbc.conf
- run
bin/logstash -f jdbc.conf
# This will start logstash service, which will sync data from postgres to ES cloud
-
run
go run cmd/main.go
- This will start golang rest api service
Sample curl for all apis
-
Search for projects created by a particular user curl 'localhost:8080/projects/created-by/1' Where 1 is the user ID
-
Search for projects that use specific hashtags** curl 'localhost:8080/projects/search-with-hashtags'
--header 'Content-Type: application/json'
--data '{ "hashtags":["programming","design"] }' -
Full-text fuzzy search for projects curl 'localhost:8080/projects/search?q=project'
Pending tasks:
- AWS postgres connectivity issue (alternatively using local postgres)
- Pass secrets to env from terraform out and use them in app/scripts
- Move logstash setup to aws via terraform
- Handle logstash for delete operation in postgres
- Code documentation and unit test cases
Loom video link for code flow : https://www.loom.com/share/538c14fd18c4421eb026d4296408ff08?sid=c30ec23c-0c7a-47b4-a0ae-499be611a071
Look video link for checking sync b/w postgres and ES/APIs : https://www.loom.com/share/6debd5bb8a184ad98f88e3e5fa46f0b8?sid=ea6eb2e6-c45e-429d-ad70-f96731e055f4