{"id":28718629,"url":"https://github.com/omsingh2003/vaultguard-api","last_synced_at":"2025-06-15T05:02:05.555Z","repository":{"id":288668937,"uuid":"968844998","full_name":"OmSingh2003/VaultGuard-API","owner":"OmSingh2003","description":"Engineered a production-grade Go backend for a banking platform, featuring dual REST/gRPC APIs (Gin/gRPC Gateway). It ensures data integrity with PostgreSQL (SQLC/migrations) and provides robust JWT/PASETO authentication. Asynchronous task processing (Redis/Asynq) enhances responsiveness, all deployed via Docker and CI/CD pipelines.","archived":false,"fork":false,"pushed_at":"2025-06-09T15:53:19.000Z","size":27217,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-09T16:43:40.168Z","etag":null,"topics":["docker","gin","golang","grpc-go","http-server","kubernetes","postgresql","redis"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OmSingh2003.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-18T20:58:28.000Z","updated_at":"2025-06-09T15:53:23.000Z","dependencies_parsed_at":"2025-06-09T16:43:41.522Z","dependency_job_id":null,"html_url":"https://github.com/OmSingh2003/VaultGuard-API","commit_stats":null,"previous_names":["omsingh2003/simple-bank","omsingh2003/vaultguard-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/OmSingh2003/VaultGuard-API","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OmSingh2003%2FVaultGuard-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OmSingh2003%2FVaultGuard-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OmSingh2003%2FVaultGuard-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OmSingh2003%2FVaultGuard-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OmSingh2003","download_url":"https://codeload.github.com/OmSingh2003/VaultGuard-API/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OmSingh2003%2FVaultGuard-API/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259924667,"owners_count":22932781,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","gin","golang","grpc-go","http-server","kubernetes","postgresql","redis"],"created_at":"2025-06-15T05:01:49.452Z","updated_at":"2025-06-15T05:02:05.538Z","avatar_url":"https://github.com/OmSingh2003.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# VaultGuard API\n\n[![Go Version](https://img.shields.io/badge/Go-1.24+-blue.svg)](https://golang.org/)\n[![CI Test Status](https://github.com/OmSingh2003/vaultguard-api/actions/workflows/ci-test.yml/badge.svg)](https://github.com/OmSingh2003/vaultguard-api/actions/workflows/ci-test.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nFull-featured backend system for VaultGuard API built with Go. Implements REST/gRPC APIs (Gin/gRPC Gateway), PostgreSQL DB access (SQLC \u0026 migrations), JWT/PASETO authentication, asynchronous task processing (Redis/Asynq), Docker deployment strategies, and CI/CD pipelines.\n\n**Status:** Currently under active development.\n\n## ✨ Features\n\n* **RESTful API:** Built with [Gin](https://github.com/gin-gonic/gin) for core banking operations (accounts, transfers, entries).\n* **gRPC API:** High-performance RPC framework for inter-service communication and client SDK generation.\n* **gRPC Gateway:** Translates RESTful JSON API requests into gRPC messages, allowing one API definition for both. Includes embedded Swagger UI.\n* **Database:** PostgreSQL database integration.\n* **Type-Safe SQL:** Uses [SQLC](https://github.com/sqlc-dev/sqlc) to generate type-safe Go code from SQL queries.\n* **DB Migrations:** Manages database schema changes using [golang-migrate](https://github.com/golang-migrate/migrate).\n* **Authentication:** Secure user authentication using both JWT and PASETO tokens.\n* **Asynchronous Tasks:** Background task processing (e.g., sending verification emails) using Redis and [Asynq](https://github.com/hibiken/asynq).\n* **Dockerized:** Fully containerized application using Docker and Docker Compose for consistent environments.\n* **Configuration:** Centralized configuration management using [Viper](https://github.com/spf13/viper).\n* **Logging:** Structured logging using [Zerolog](https://github.com/rs/zerolog).\n* **CI/CD:** Automated testing and build pipelines (e.g., using GitHub Actions - *placeholder*).\n\n## 🛠️ Tech Stack\n\n* **Language:** [Go](https://golang.org/) (version 1.24+)\n* **API Frameworks:** [Gin](https://github.com/gin-gonic/gin), [gRPC](https://grpc.io/), [gRPC Gateway](https://github.com/grpc-ecosystem/grpc-gateway)\n* **Database:** [PostgreSQL](https://www.postgresql.org/)\n* **ORM/SQL Builder:** [SQLC](https://github.com/sqlc-dev/sqlc)\n* **Migrations:** [golang-migrate](https://github.com/golang-migrate/migrate)\n* **Async Tasks:** [Redis](https://redis.io/), [Asynq](https://github.com/hibiken/asynq)\n* **Authentication:** JWT ([golang-jwt](https://github.com/golang-jwt/jwt)), PASETO ([paseto](https://github.com/o1egl/paseto))\n* **Configuration:** [Viper](https://github.com/spf13/viper)\n* **Logging:** [Zerolog](https://github.com/rs/zerolog)\n* **Containerization:** [Docker](https://www.docker.com/), [Docker Compose](https://docs.docker.com/compose/)\n* **Build/Task Runner:** [Make](https://www.gnu.org/software/make/)\n* **DB Documentation:** [DBML](https://dbml.org/), [dbdocs](https://dbdocs.io/)\n* **Mocking:** [Gomock](https://github.com/golang/mock)\n\n## 📋 Prerequisites \u0026 Tool Installation\n\nEnsure you have the following core tools installed:\n\n* [Go](https://golang.org/doc/install) (version 1.19 or higher)\n* [Docker Desktop](https://docs.docker.com/get-docker/) (includes Docker \u0026 Docker Compose)\n* [Make](https://www.gnu.org/software/make/)\n* Optional DB GUI: [TablePlus](https://tableplus.com/) or similar\n\nInstall project-specific CLI tools:\n\n* **Homebrew (macOS):** If using macOS, [install Homebrew](https://brew.sh/) first.\n* **Migrate CLI:** Manages database migrations.\n    ```bash\n    # Using Homebrew (macOS)\n    brew install golang-migrate\n    # Or build from source (other OS) - see golang-migrate docs\n    ```\n* **SQLC CLI:** Generates Go code from SQL.\n    ```bash\n    # Using Homebrew (macOS)\n    brew install sqlc\n    # Or build from source (other OS) - see sqlc docs\n    ```\n* **buf CLI:** Manages Protobuf files.\n    ```bash\n    # Using Homebrew (macOS)\n    brew install bufbuild/buf/buf\n    # Or see buf installation docs\n    ```\n* **Gomock:** Generates mock code for testing.\n    ```bash\n    go install [github.com/golang/mock/mockgen@v1.6.0](https://github.com/golang/mock/mockgen@v1.6.0)\n    ```\n* **DBML CLI:** Converts DBML to SQL (for schema generation).\n    ```bash\n    npm install -g @dbml/cli\n    # Verify installation\n    dbml2sql --version\n    ```\n* **dbdocs CLI:** Generates database documentation website.\n    ```bash\n    npm install -g dbdocs\n    # Login to dbdocs service (required for hosting)\n    dbdocs login\n    ```\n\n## 🚀 Local Development Setup\n\nFollow these steps to set up the project for local development:\n\n1.  **Clone the repository:**\n    ```bash\n    git clone [https://github.com/OmSingh2003/vaultguard-api.git](https://github.com/OmSingh2003/vaultguard-api.git)\n    cd vaultguard-api\n    ```\n\n2.  **Set up Environment Variables:**\n    Copy the example environment file and update it with your specific configuration.\n    ```bash\n    cp .env.example .env\n    ```\n    * Modify `.env` with your database credentials (use defaults if using `make postgres`), token symmetric keys, Redis address, etc.\n\n3.  **Setup Infrastructure (Docker Network \u0026 Postgres):**\n    This creates a dedicated Docker network and starts a PostgreSQL container.\n    ```bash\n    # Create the docker network (if it doesn't exist)\n    make network\n\n    # Start postgres container\n    make postgres\n    ```\n\n4.  **Create Database:**\n    Connects to the running Postgres container and creates the `vaultguard_api` database.\n    ```bash\n    make createdb\n    ```\n\n5.  **Run Initial Database Migration:**\n    Applies all available migrations to set up the database schema.\n    ```bash\n    make migrateup\n    ```\n\n6.  **Install Go Dependencies:**\n    ```bash\n    go mod tidy\n    ```\n\n7.  **Generate Code (SQLC, Mocks, Protobuf):**\n    This step generates necessary Go code based on SQL queries, Protobuf definitions, and creates mocks for testing.\n    ```bash\n    # Generate Go code from SQL queries in db/query/\n    make sqlc\n\n    # Generate gRPC, gRPC-gateway, and Swagger code from proto files\n    make proto\n\n    # Generate mock code for testing interfaces\n    make mock\n    ```\n\n8.  **Build the Application:**\n    Compiles the Go application binaries.\n    ```bash\n    make build\n    ```\n\n## ▶️ Running the Application\n\n**Using Docker Compose (Recommended):**\n\nThis starts all services (PostgreSQL, Redis, API server, gRPC server, async worker) defined in `docker-compose.yml`.\n\n```bash\ndocker-compose up --build\n(The --build flag ensures images are rebuilt if code changes)Using Make (Requires Manual Service Management):If you prefer not to use Docker Compose for the Go services (but still use make postgres for the DB):# Start the main API server (REST \u0026 gRPC Gateway)\nmake server\n\n# (In another terminal) Start the asynchronous task worker\nmake worker\nThe REST API server typically runs on :8080.The gRPC server typically runs on :9090.The Asynq web UI (if enabled) runs on :8081.🧪 Running TestsTo run the test suite:make test\n(This usually runs go test -v -cover ./...)🔄 Migrations ManagementUse Make commands to manage database schema migrations:Apply all pending migrations:make migrateup\nApply the next pending migration:make migrateup1\nRoll back all migrations:make migratedown\nRoll back the last applied migration:make migratedown1\nCreate a new migration file:Replace \u003cmigration_name\u003e with a descriptive name (e.g., add_users_table).make new_migration name=\u003cmigration_name\u003e\n📄 Database DocumentationGenerate and view database documentation using DBML and dbdocs:Generate DBML schema file (if needed):(This might be manual or part of another process depending on your setup)Generate schema SQL file from DBML:(Useful for visualizing or comparing)make db_schema\nGenerate and publish documentation website:(Requires prior dbdocs login)make db_docs\n    Access the DB documentation at the URL provided by the command output. (Password: secret - as noted in your input, consider if this should be documented or secured differently)📄 API Documentation (Swagger)API documentation is automatically generated from the Protobuf definitions and served via Swagger UI.Once the server is running (using docker-compose up or make server), access the Swagger UI at:http://localhost:8080/swagger/☁️ Deployment (Kubernetes Example)These are example steps for setting up prerequisites in a Kubernetes cluster for deployment:Install Nginx Ingress Controller:(Example for AWS, check provider docs for others)kubectl apply -f [https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.48.1/deploy/static/provider/aws/deploy.yaml](https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.48.1/deploy/static/provider/aws/deploy.yaml)\nInstall Cert-Manager:(For automatic TLS certificate management)kubectl apply -f [https://github.com/jetstack/cert-manager/releases/download/v1.4.0/cert-manager.yaml](https://github.com/jetstack/cert-manager/releases/download/v1.4.0/cert-manager.yaml)\n(Note: Ensure you use versions compatible with your cluster. These are examples.)(Add specific deployment steps for the VaultGuard API application itself here, e.g., applying Kubernetes manifests for Deployments, Services, Ingress, Secrets, etc.)🏗️ Project Structure (Overview).\n├── api         # Gin handlers, middleware, server setup\n├── cmd         # Main application entry points (server, worker)\n├── db          # Database migrations and SQLC queries/schema\n├── gapi        # gRPC handlers, interceptors, server setup\n├── internal    # Core business logic, domain types (shared internal code)\n├── mail        # Mail sending logic\n├── pb          # Generated Protobuf Go code\n├── proto       # Protobuf definition files\n├── token       # JWT/PASETO token generation and verification logic\n├── util        # Utility functions (config, logging, etc.)\n├── worker      # Asynq task definitions and processor setup\n├── .env.example # Example environment variables\n├── Dockerfile  # Docker build instructions\n├── docker-compose.yml # Docker Compose service definitions\n├── go.mod      # Go module dependencies\n├── Makefile    # Make targets for common tasks\n└── main.go     # Main application entry point (often calls cmd)\n(Adjust this structure based on your actual project layout)🔄 CI/CDThis project uses GitHub Actions for continuous integration. The workflow includes:Running linters (golangci-lint).Running unit tests.Building the application.(Describe your specific CI/CD setup here)🤝 ContributingContributions are welcome! Please follow standard Go practices and ensure tests pass before submitting a pull request.(Add more detailed contribution guidelines if needed)📜 LicenseThis project is licensed under the MIT License - see the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomsingh2003%2Fvaultguard-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomsingh2003%2Fvaultguard-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomsingh2003%2Fvaultguard-api/lists"}