This project is a handy web app that helps manage info about users, patients, and nurses. It's built with Go and the Gin web framework, and it uses a PostgreSQL database to keep all the data safe and sound.
- Go 1.20 or later
- PostgreSQL 13 or later
- Docker (optional)
- AWS S3 bucket (optional; for image upload)
Here are the steps to install the project:
-
Clone the repository:
git clone https://github.com/hnfnfl/halo-suster-be.git
-
Navigate to the project directory:
cd halo-suster-be
-
Install the required dependencies:
go mod tidy
-
Build the binary using Makefile:
make build
-
Set up the configuration file in
local_configuration/config.yaml
-
Migrate the database schema:
make migrate-up
-
Run the server:
make run
-
The server should be running on
localhost:8080
Also, you can run the server using Docker:
-
Build the Docker image:
make docker-build
-
Update the environment variables in
docker-compose.yml
-
Run the Docker container:
make docker-run
The configuration file is located in local_configuration/config.yaml
. This file contains the configuration for the database, logging, JWT, and AWS S3.
Here's an example of the configuration file:
Environment: development # development, production
LogLevel: debug # debug, info, warn, error
AUTHEXPIRY: 1 # in hours
DB:
Name: mydb # database name
Port: 5432 # database port
Host: localhost # database host
Username: postgres # database username
Password: admin # database password
Params: sslmode=disable # database connection parameters
MaxIdleConns: 20 # maximum idle connections
MaxOpenConns: 20 # maximum open connections
Jwt:
Secret: mysecret # JWT secret key
BcryptSalt: 10 # Bcrypt salt
AWS:
Access.Key.ID: myaccesskey # AWS access key ID
Secret.Access.Key: mysecretaccesskey # AWS secret access key
S3.Bucket.Name: mybucketname # AWS S3 bucket name
Region: ap-southeast-1 # AWS region
The following endpoints are available:
POST /v1/user/it/register
: Register a new user with the IT rolePOST /v1/user/it/login
: Log in for an IT staffPOST /v1/user/nurse/register
: Register a new nursePOST /v1/user/nurse/login
: Log in for a nursePUT /v1/user/nurse/:userId
: Update a nurse's infoDELETE /v1/user/nurse/:userId
: Delete a nurse from the databaseGET /v1/user/
: Get all usersPOST /v1/medical/patient
: Register a new patientGET /v1/medical/patient
: Get all patientsPOST /v1/medical/record
: Create a new medical record for a patientGET /v1/medical/record
: Get all medical records for a patientPOST /v1/image
: Upload an image to an AWS S3 bucket