Courtly Service is a backend service of Courtly: Easily Order Court Application. Courtly-Service is designed to facilitate seamless service management for sports court rentals. This server is built to manage user offerings, handle bookings, and connect efficiently.
- API for Booking Management: Manage bookings and availability for sports fields.
- Vendor Service Management: APIs for vendors to add and manage their services.
- Authentication and Authorization: Secure access with token-based authentication.
- Scalable Architecture: Designed for high performance and scalability.
- Programming Language: Go (Golang)
- Framework: Echo and GORM
- Database: MySQL
- Authentication: JWT (JSON Web Tokens)
- Go: Install Go.
- MySQL: Ensure MySQL is installed and running.
- ngrok: Temporary deploy the service server for midtrans payment callback, Install ngrok.
There are several available endpoints, such as:
- POST
/api/v1/auth/user/login
- Sign user with an existing account - POST
/api/v1/auth/user/register
- Register a new user account - POST
/api/v1/auth/user/logout
- Remove user from authenticated status - POST
/api/v1/auth/user/verify-password
- Verify current user password - POST
/api/v1/auth/vendor/verify-password
- Verify current vendor password - POST
/api/v1/auth/vendor/login
- Sign vendor with an existing account - POST
/api/v1/auth/vendor/logout
- Remove vendor from authenticated status
- GET
/api/v1/users/me
- Get current user information from the database - PATCH
/api/v1/users/me/password
- Update user password with a new password - PATCH
/api/v1/users/me/username
- Update user username with a new available username - PATCH
/api/v1/users/me/profile-picture
- Update user profile picture with a new profile image
- GET
/api/v1/vendors/me
- Get current vendor information from database - PATCH
/api/v1/vendors/me/password
- Update vendor password with a new password
- GET
/api/v1/users/me/orders
- Get current user orders overview from database - GET
/api/v1/users/me/orders/reorder
- Create a new order from existing order from database - POST
/api/v1/users/me/orders
- Create a new current user order and payment - GET
/api/v1/users/me/orders/:id
- Get current user order details from database - GET
/api/v1/vendors/me/orders
- Get current vendor orders overview from database - GET
/api/v1/vendors/me/orders/stats
- Get current vendor orders stats from database - GET
/api/v1/vendors/me/orders/:id
- Get current vendor order details from database
- GET
/api/v1/courts
- Get all available courts from database - GET
/api/v1/vendors/:id/courts/:type
- Get vendor courts using vendor id and court type from database - GET
/api/v1/vendors/:id/courts/:type/bookings
- Get vendor court booking datas using vendor id and court type from database - GET
/api/v1/vendors/me/courts/:type
- Get current vendor courts using court type from database - PUT
/api/v1/vendors/me/courts/:type
- Update current vendor courts using court type from database - GET
/api/v1/vendors/courts/:type/bookings
- Get current vendor court type based on court type from database - POST
/api/v1/vendors/me/courts/:type/new
- Create a new court for a court type - POST
/api/v1/vendors/me/courts/:type
- Create a new court for a court type from the existing court - GET
/api/v1/vendors/me/courts/stats
- Get current vendor courts stats from database
- GET
/api/v1/vendors/:id/courts/:type/reviews
- Get vendor courts type reviews from database - GET
/api/v1/vendors/me/reviews
- Get court reviews related to the vendor from database - POST
/api/v1/vendors/:id/courts/:type/reviews
- Create a new review for current vendor and court type
- GET
/api/v1/fees
- Get all service fees related to bussiness transactions
- GET
/api/v1/advertisements
- Get all available advertisements related to the vendor and vendor's court
- GET
/midtrans/payment-callback
- A payment callback endpoint to mark an order status as success
Since this service relies on REST API, so json is pretty much needed here. All endpoints have the same json response structure (in general), which shown as an example below.
{
"success": true,
"message": "...",
"data": {
"..."
}
}
From the example, we can see there are 3 properties in the response body, which will be explained below.
"success"
- The success status of the response, this could be either true or false."message"
- The message of the response, this could be either a success message, failed message, or error messages for inputs"data"
- The passed data to the frontend server. The data structure could be different for each endpoint response, so make sure to read the response carefully
To see responses structure in details, please read this doc.
To start the service, make sure to follow the steps below.
- Clone the repository:
git clone https://github.com/bryanfks-dev/Courtly-Service.git
cd Courtly-Service
- Install depedencies:
go mod tidy
- Clone the environment file
cp .env.example .env
-
Go to midtrans website, find your midtrans server key, and copy it to clipboard.
-
Set up the environment variables:
# Database Configuration
DB_HOST=<your-db-host>
DB_PORT=<your-db-port>
DB_USERNAME=<your-dh-username>
DB_PASSWORD=<your-dh-password>
DB_DATABASE=courtly_db
# Server Configuration
SERVER_HOST=localhost
SERVER_PORT=3000
# JWT Configuration
JWT_SECRET=<your-jwt-secret>
# Payment Gateway Configuration
MIDTRANS_API_KEY=<your-midtrans-server-key>
- Run the server:
go run main.go
The server will start on port that you've set based on the environtment variable (e.g. :3000).
- Start ngrok:
ngrok http <port-to-listen>
- Copy the generated ngrok link, then paste the link into the Payment Notification URL in the midtrans website with the given format:
<ngrok-url>/midtrans/payment-callback
This project is open-source and available under the MIT License.