Categorygithub.com/TrinityKnights/Backend
repository
0.0.0-20250104101730-73c827336c6e
Repository: https://github.com/trinityknights/backend.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# README

TrinityKnights Backend

TrinityKnights Backend is a service that provides backend functionalities for the TrinityKnights application.

Go GitHub code size in bytes Go Report Card License

Table of Contents

Features

  • Authentication & Authorization

    • JWT-based authentication
    • Role-based access control (Admin/Public)
    • Token refresh mechanism
  • Payment Processing

    • Xendit payment gateway integration
    • Payment status tracking
    • Invoice generation
    • Payment search and filtering
  • API Interfaces

    • RESTful HTTP API
    • GraphQL API with playground
    • Swagger/OpenAPI documentation
  • Data Management

    • PostgreSQL database integration
    • Redis caching
    • GORM ORM implementation
  • Development Features

    • Docker and Docker Compose support
    • Comprehensive test coverage
    • Mock generation for testing
    • Code quality checks (critic, security)
    • Hot reload in development

Deployment

  • Koyeb

Deploy to Koyeb

  • Railway

Deploy on Railway

  • Vercel

Deploy with Vercel

  • Render

Deploy to Render

Requirements

  • Go 1.23+
  • Docker
  • PostgreSQL
  • Redis
  • Make

Installation

  1. Clone the repository:

    git clone https://github.com/savioruz/TrinityKnights.Backend.git
    cd TrinityKnights.Backend
    
  2. Environment Variables:

    Create a .env file in the root directory and add the following:

    cp .env.example .env
    
  3. Edit the .env file with your configuration:

    APP_PORT=3000
    APP_LOG_LEVEL=6
    APP_ENV=development
    
    DB_HOST=
    DB_PORT=5432
    DB_USER=
    DB_PASSWORD=
    DB_NAME=
    DB_SSL_MODE=require
    DB_TIMEZONE=
    
    REDIS_HOST=
    REDIS_PORT=
    REDIS_PASSWORD=
    REDIS_DB=0
    
    SMTP_HOST=
    SMTP_PORT=
    SMTP_USERNAME=
    SMTP_PASSWORD=
    
    JWT_SECRET=
    JWT_ACCESS_EXPIRY=1h
    JWT_REFRESH_EXPIRY=168h
    
    XENDIT_API_KEY=
    XENDIT_CALLBACK_TOKEN=
    

Usage

Development Commands

# Generate Swagger documentation
make swag

# Generate mocks for testing
make mockgen

# Run code critics (static analysis)
make critic

# Run security checks
make security

# Run tests with coverage
make test

Docker Commands

Single Container

# Build Docker image
make docker.build

# Run container
make docker.run

# Stop and remove container
make docker.stop

Docker Compose

# Build services
make dc.build

# Start services
make dc.up

# Stop services
make dc.down

Testing

Run the full test suite with coverage:

make test

This will:

  1. Clean build artifacts
  2. Run code critics
  3. Perform security checks
  4. Execute tests with coverage
  5. Display coverage report

Code Generation

Generate mock implementations for testing:

make mockgen

Generate Swagger documentation:

make swag

Running the API

You can run the API using Docker or directly with Make.

Docker

  1. Run redis:

    make docker.redis
    
  2. Run the application:

    make docker.run
    

For production, you need to secure redis on Makefile with a password.

Make

  1. Run the application:

    make run
    

You need to have Redis running on your machine.

ERD Schema

ERD Schema

API Documentation

Swagger documentation is available at: http://localhost:3000/swagger.

GraphQL Playground

GraphQL playground is available at: http://localhost:3000/playground.

Project Structure

.
├── cmd/
│   └── app/main.go
├── config/
├── docs/
├── internal/
│   ├── builder/
│   ├── delivery/
│   │   ├── graph/
│   │   │   ├── handler/
│   │   │   ├── model/
│   │   │   ├── resolver/
│   │   │   └── schema.graphqls
│   │   └── http/
│   │   │   ├── handler/
│   │   │   ├── middleware/
│   │   │   └── route/
│   ├── domain/
│   │   ├── entity/
│   │   └── model/
│   │       └── converter/
│   ├── repository/
│   └── service/
├── pkg/
│   ├── cache/
│   ├── errors/
│   ├── helper/
│   └── route/
├── test/mock
├── .env
├── .env.example
├── .gitignore
├── Dockerfile
├── docker-compose.yml
├── tools.go
├── go.mod
├── go.sum
├── Makefile
├── README.md
├── vercel.json
└── LICENSE
    

Contributing

Feel free to open issues or submit pull requests with improvements.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Reference

Acknowledgements