The Go Base API is a secure, robust foundation for building mobile application servers and other Go-based projects. It features comprehensive user management and authentication systems, ensuring secure access and data integrity. Initially developed for the Penpals app, this API serves as a versatile starting point for any Go developer looking to accelerate their project development with pre-built, reliable backend functionality.
This project is used by the following projects:
Penpals
: An AI-based app designed to make learning new languages easy and intuitive through conversations with artificial intelligence pen pals
To configure your application correctly, you will need to set the following environment variables. These variables allow the application to connect to external services like PostgreSQL and Redis, and to configure security parameters for token management.
POSTGRES_HOST
: Hostname of the PostgreSQL server. Default is localhost.
POSTGRES_PORT
: Port on which the PostgreSQL server is running. Replace port with the actual port number.
POSTGRES_USER
: Username for accessing the PostgreSQL database.
POSTGRES_PASSWORD
: Password for the PostgreSQL user.
POSTGRES_DATABASE
: Name of the database to connect to.
POSTGRES_SSLMODE
: SSL mode for the PostgreSQL connection. Typical values are disable, require, and verify-full.
REDIS_HOST
: Hostname of the Redis server. Default is localhost.
REDIS_PORT
: Port on which the Redis server is running. Replace
port with the actual port number.
REDIS_PASSWORD
: Password to access the Redis server, if applicable.
CLIENT_ORIGIN
: Specifies the origin of the clients that are allowed to access the server, typically used for CORS settings. Default is localhost.
ACCESS_TOKEN_PRIVATE_KEY
: Private key for signing JWT access tokens.
ACCESS_TOKEN_PUBLIC_KEY
: Public key for verifying JWT access tokens. Should match the private key.
ACCESS_TOKEN_EXPIRED_IN
: Lifespan of the access token. Default is 15m (15 minutes).
ACCESS_TOKEN_MAXAGE
: Maximum age (in seconds) that the access token is considered valid. Default is 15.
REFRESH_TOKEN_PRIVATE_KEY
: Private key for signing JWT refresh tokens.
REFRESH_TOKEN_PUBLIC_KEY
: Public key for verifying JWT refresh tokens. Should match the private key.
REFRESH_TOKEN_EXPIRED_IN
: Lifespan of the refresh token. Default is 60m (60 minutes).
REFRESH_TOKEN_MAXAGE
: Maximum age (in seconds) that the refresh token is considered valid. Default is 60.
POSTGRES_USER
: Username for accessing the PostgreSQL database.
POSTGRES_PASSWORD
: Password for the PostgreSQL user.
POSTGRES_DATABASE
: Name of the database to connect to.
REDIS_PASSWORD
: Password to access the Redis server, if applicable.
TARGET
: The environment targeted (development, production, ...)
Create the TLS directory
mkdir -p tls
Add your SSL/TLS certificate and private key
cp path/to/your/cert.pem tls/cert.pem
cp path/to/your/key.pem tls/key.pem
Verify the files are correctly placed
ls tls
Clone the project
git clone https://github.com/enzo-gbd/GBA
Go to the project directory
cd GBA
Build the docker
cd docker
docker-compose up -d