How alrf/go_redis_pg works
Project type and purpose
• This is a backend-focused Golang REST API service that exposes a single endpoint (/humai/echoservice).
• It persists incoming JSON payloads into Redis (cache) and PostgreSQL (primary store), and returns augmented JSON (adds timestamp).
• It uses Docker and docker-compose to orchestrate containers for the API, Redis, PostgreSQL, and a Jenkins server for CI/CD.
File structure
• Top-level:
• Dockerfile, .dockerignore, docker-compose.yml, .env, Makefile
• app/ contains the Go code (main.go, controllers, models, utils, go.mod/sum)
• data/ holds persistent volumes for Redis and PostgreSQL
• services/jenkins/ defines the Jenkins container, its Dockerfile, and pipeline config (init.groovy, jobs.groovy)
• Patterns & configs:
• Multi-stage Docker build in Dockerfile (builder → app)
• docker-compose.yml ties together four services: go-api, redis, postgres, jenkins
• Makefile automates curl-based tests
• Jenkins pipeline defined in services/jenkins/config/jobs.groovy
README for additional insights
• Endpoint behavior: POST checks Redis → if miss, write to Redis & PostgreSQL → respond with original payload + timestamp. GET returns last 10 entries from PostgreSQL.
• CI pipeline: clone repo → build Docker image → push to Docker Hub.
• Deployment steps: docker-compose up/down.
Detail without overthinking
• Every container and its role
• Sequence: code → Jenkins → build → Docker Hub → deploy → runtime
• Cache-aside logic step by step
• Persistent volume mounts from data/ directory