Categorygithub.com/DarrelA/starter-go-postgresql
module
0.0.0-20250101110151-d73ece1f121c
Repository: https://github.com/darrela/starter-go-postgresql.git
Documentation: pkg.go.dev

# README

Intro

This is a Golang-based web application leveraging PostgreSQL for data storage, Redis for refresh token management, and an architectural foundation rooted in Hexagonal Architecture (Hex Arch) and Domain-Driven Design (DDD).

Overview

  • Golang and PostgreSQL: The application uses Go for its backend services, with PostgreSQL as the primary database for data storage and retrieval. This combination ensures high performance and reliability.
  • Refresh Token Management with Redis: User authentication and session management are handled securely using Redis for storing refresh tokens, ensuring quick access and improved security.
  • Hexagonal Architecture and Domain-Driven Design: Hex Arch principles and DDD create a modular, maintainable codebase, facilitating clear boundaries between the core domain logic and peripheral components.
  • Fiber Web Framework and Zerolog: The project tightly couples the Fiber web framework and Zerolog to leverage the high performance and minimalistic design of Fiber along with Zerolog's efficient structured logging. This integration streamlines development, enhances debugging and monitoring capabilities, and reduces boilerplate code, though it introduces some tradeoffs in flexibility and complexity.

Documentation

For more detailed information on the setup, architecture, and various components of this project, refer to the Docs folder.

Setup

Handle Initial Files

  1. Respective .env files in internal/infrastructure/config folder
  2. Respective env server .json file in internal/infrastructure/db/postgres/json folder: Establishes server connection from pgAdmin to Postgres
  3. Run chmod command for the shell script(s)

Generate the Private and Public Keys

Shell Script

# generate keys in base64
# alternatively use the browser method
chmod +x deployment/build/scripts/refresh_token_keygen.sh
cd build/scripts && ./refresh_token_keygen.sh && cd ../..

# Format app.log
chmod +x deployment/build/scripts/format_app_log.sh

Browser Method

  1. Online RSA Key Generator: Key Size: 2048 bit
  2. BASE64 Decode and Encode

(back to top)

Shell

directory

brew install tree # MacOS
tree -d

testing

# makefile defaults to dev env
make wat

psql

# pgAdmin
http://localhost:5050/browser/

# If not using pgAdmin
docker exec -it postgres bash

# List all databases
psql -U user1 -d postgres
\l

# View table
psql -U user1 -d pgstarter
SELECT * FROM users;

redis

docker exec -it redis /bin/sh
redis-cli
INFO

KEYS *
# Get the value of the key (user_uuid)
GET key
# Check the remaining time to live (TTL) of a key
TTL key

(back to top)

# Packages

No description provided by the author