# README
FP PBKK Golang
This repository contains the final project for the Framework-Based Programming course, developed using the Go programming language.
Authors
NRP | Nama |
---|---|
5025221002 | Iftala Zahri Sukmana |
5025221252 | Revy Pramana |
API Documentation
https://documenter.getpostman.com/view/32470266/2sAYBYeV5b
Quick Start
To set up and run the project locally, follow these steps:
-
Clone the Repository:
git clone https://github.com/Revprm/go-fp-pbkk.git
-
Navigate to the Project Directory:
cd go-fp-pbkk
-
Copy the Example Environment File:
cp .env.example .env
-
Install Dependencies:
Ensure you have Go installed. Then, run:
go mod tidy
-
Run Database Migrations:
go run main.go --migrate
-
Start the Application:
go run main.go
The application should now be running on http://localhost:8080
.
Program Flow
The application follows a clean architecture pattern, ensuring separation of concerns and maintainability.
request
> router > controller > service > repository > service > controller > router > response
Commands
-
Run the Application:
go run main.go
-
Run Database Migrations:
go run main.go --migrate
-
Run Tests:
go run main.go --test
Directory Structure
The project is organized as follows:
go-fp-pbkk/
├── command/ # CLI commands
├── config/ # Configuration files
├── constants/ # Constant values used across the application
├── controller/ # HTTP request handlers (controller layer)
├── dto/ # Data Transfer Objects
├── entity/ # Database entities (data layer)
├── helpers/ # Utility functions
├── middleware/ # HTTP middleware
├── migrations/ # Database migration files
├── repository/ # Data access layer
├── routes/ # API route definitions
├── script/ # Auxiliary scripts
├── service/ # Business logic layer (service layer)
├── tests/ # Test cases
├── utils/ # Utility functions
└── main.go # Entry point of the application
Response Format
{
"status": true | false,
"message": string,
"error": null | "Error description (for failures)",
"data": null | "Payload of the response (optional)",
"meta": null | "Pagination metadata (optional)"
}
Response Structure:
- Success
- Error
- Pagination
Success
{
"status": true,
"message": string,
"data": [] or {} (optional)
}
Error
{
"status": false,
"message": string,
"error": string,
"data": null
}
Pagination
{
"status": true,
"success": string,
"data": PaginationData{}
}
PaginationData
{
"page": number,
"per_page": number,
"max_page": number,
"count": number
}