This repository contains the backend service for the Kampung Budaya Festival, built using the Golang programming language and the Gorilla Mux router. The service also utilizes Swagger for API documentation, powered by the Swaggo/Swag module. Additionally, the project includes a database migration setup managed through the go-migrate module and controlled using the provided Makefile.
Follow these instructions to set up and run the backend service locally.
- Golang must be installed on your machine. If not, you can download it from the official Golang website.
- Ensure you have a MySQL/MariaDB database available.
- Make package to run make automated commands
- Migrate CLI to run migration file
-
Clone the repository:
git clone https://github.com/KampungBudaya/Kampung-Budaya-2023-BE.git cd Kampung-Budaya-2023-BE
-
Copy
.env.example
file to.env
in the project root directory and set your database credentials:cp .env.example .env
-
Place your Firebase JSON credential in the root directory, alongside the .env file
cp ~/firebase_credential.json .
-
Install project dependencies:
go mod download
-
Run the database migrations using the provided Makefile:
make migrate-up
-
Build and run the service:
make up
The service should now be running locally at http://localhost:8080
or any port you desire to use.
The API documentation for the backend service can be accessed through Swagger UI. After starting the service locally, navigate to http://localhost:8080/swagger/index.html to view and interact with the API endpoints.
The database migration scripts are managed using the go-migrate module. You can use the provided Makefile commands to handle migrations.
make up
: Run the servermake migrate-up
: Apply database migrations.make migrate-down
: Drop all migration tables.make migrate-drop
: Drop entire schema's table.make migrate-version
: Display the current migration version.
Contributions are welcome! If you find any issues or have improvements to suggest, please feel free to open an issue or submit a pull request.