Skip to content

Portfolio Backend API – The backend powering my portfolio website, built with Golang and Gin. © 2025 Rama Diaz. All Rights Reserved. Unauthorized use, copying, modification, or distribution is prohibited.

License

Notifications You must be signed in to change notification settings

ramadiaz/profile-api

Repository files navigation

Go Version Gin Framework GORM PostgreSQL Validator Mapstructure Wire License



Logo

Xanny Go Template

An awesome Golang API template to jumpstart your projects!
Explore the docs »

Report Bug · Request Feature

About The Project

Xanny Go Template is a robust and scalable boilerplate for building RESTful APIs using Go (Golang). Designed with best practices and modern development in mind, this template serves as a starting point for backend projects, enabling developers to quickly set up and customize their API solutions.

Key Features

  • Modular Architecture: Organized with a clean directory structure, separating concerns for better maintainability and scalability.
  • Layered Approach: Implements the handler-service-repository pattern to keep business logic, data access, and API handling separate.
  • Gin Framework: Leverages the powerful and minimalist Gin framework for efficient request handling and routing.
  • ORM Support: Uses GORM for database interactions, providing an easy and familiar way to handle models and migrations.
  • Configuration Management: Centralized configuration management to simplify environment-specific settings using Viper.
  • JWT Authentication: Secure authentication mechanism using JSON Web Tokens (JWT) for stateless and secure user sessions.
  • Custom Error Handling: Centralized error management to ensure consistent and informative API responses.
  • Auto-Migrations: Automated database migrations using a dedicated migration script for seamless schema updates.
  • Makefile Automation: Includes a Makefile for common tasks such as running the application, building binaries, and executing migrations.

Why Use Xanny Go Template?

This template is ideal for developers looking for a ready-to-use, yet flexible structure for their Go backend projects. By providing essential features out-of-the-box, it allows you to focus on building core functionalities without worrying about boilerplate code.

Built With

Xanny Go Template is built using a combination of powerful tools and libraries that enable fast, scalable, and secure backend development. Here's a list of the technologies and frameworks used in this project:

  • Go
  • Gin Framework
  • GORM
  • PostgreSQL
  • Validator
  • Mapstructure
  • Wire

(back to top)


Getting Started

To get a local copy of Xanny Go Template up and running on your machine, follow these simple steps.

Prerequisites

Before you begin, ensure you have the following installed on your system:

  • Go (Golang): Version 1.22.1 or higher. You can download it from Go's official website.
  • Database: You need a running instance of a relational database (e.g., PostgreSQL, MySQL, or MSSQL). Make sure to set up the database and configure the connection.
  • Make: Optionally, you can install Make for automating tasks like building, running migrations, etc.

Installing

  1. Clone the repository: Open your terminal and clone the project to your local machine using Git.

    git clone https://github.com/ramadiaz/profile-api.git
    cd profile-api
  2. Install dependencies: Ensure your Go modules are set up and all dependencies are installed.

    go mod tidy
  3. Configure environment variables: Set up your environment variables by creating a .env file in the root of the project. Here's an example:

    DB_HOST=your-db-host
    DB_PORT=your-db-port
    DB_USER=your-db-username
    DB_PASSWORD=your-db-password
    DB_NAME=xanny-db
    PORT=your-desired-port
    
    JWT_SECRET=your-jwt-secret-key
    ENVIRONMENT=development
    
    ADMIN_USERNAME=your-internal-admin-username
    ADMIN_PASSWORD=your-internal-admin-password

    Replace the values with your own database connection details and secret key.

  4. Run database migrations: The template comes with a migration script to set up the necessary database tables. You can run it using the following command:

    make migrate
  5. Run the application: To start the application, you can use the following command:

    make run

    This will start the server, and the API will be accessible at http://localhost:<PORT>.

Optional: Building the Application

If you'd like to build the application binary for production use, you can run:

make build

This will compile the application into a binary located in the bin/ folder. You can then execute the binary directly.

(back to top)


Usage

Once you have set up the project and run the application, you can access the default API endpoint to verify that the server is working correctly.

Default API Endpoint

By default, the API exposes a single endpoint:

  • GET /api/ping

This endpoint will return a simple JSON response with a status of 200 and a message of "pong."

Example Request

curl http://localhost:<PORT>/api/ping

Replace <PORT> with the port number specified in your .env file.

Example Response

{
  "status": 200,
  "message": "pong"
}

This response indicates that the server is up and running. You can modify this route or add more routes as needed to expand the functionality of the API.

Customizing the Server Port

To customize the port, change the PORT value in the .env file:

PORT=your-desired-port

Then, restart the application with:

make run

The API will now be accessible at http://localhost:<your-desired-port>/api/ping.


Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)


License

Distributed under the Unlicense License. See LICENSE.txt for more information.

(back to top)


Contact

Rama Diaz - @ramadiazr - ramadiaz221@gmail.com

Project Link: https://github.com/ramadiaz/profile-api

(back to top)

About

Portfolio Backend API – The backend powering my portfolio website, built with Golang and Gin. © 2025 Rama Diaz. All Rights Reserved. Unauthorized use, copying, modification, or distribution is prohibited.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published