https://github.com/sebastianbaiju/angular-go-grpc-protocol
This project demonstrates how to establish a connection between an Angular frontend and a Go backend using the gRPC protocol. By leveraging Protocol Buffers (protobufs), we enable efficient and structured communication between the two services.
https://github.com/sebastianbaiju/angular-go-grpc-protocol
angular go grpc grpc-go
Last synced: 2 months ago
JSON representation
This project demonstrates how to establish a connection between an Angular frontend and a Go backend using the gRPC protocol. By leveraging Protocol Buffers (protobufs), we enable efficient and structured communication between the two services.
- Host: GitHub
- URL: https://github.com/sebastianbaiju/angular-go-grpc-protocol
- Owner: SebastianBaiju
- Created: 2025-02-14T11:31:42.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-25T11:35:59.000Z (over 1 year ago)
- Last Synced: 2025-05-14T02:24:13.622Z (about 1 year ago)
- Topics: angular, go, grpc, grpc-go
- Language: TypeScript
- Homepage:
- Size: 11.3 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Connecting Angular and Go with gRPC
## Overview
This project demonstrates how to establish a connection between an Angular frontend and a Go backend using the gRPC protocol. By leveraging Protocol Buffers (protobufs), we enable efficient and structured communication between the two services.
## Technologies Used
### πΉ Angular
- `@ngx-grpc/core` β Connects Angular to the gRPC server
- `@ngx-grpc/improbable-eng-grpc-web-client` β Enables gRPC-Web support
- `@ngx-grpc/well-known-types` β Provides well-known protocol buffer types
- `google-protobuf` β Handles protobuf serialization & deserialization
- `ngx-cookie-service` β Manages cookies for authentication
- `ngx-toastr` β Displays user-friendly toast notifications
- `rxjs` & `subsink` β Manages observables and subscriptions efficiently
### πΉ Go
- `google.golang.org/grpc` β Implements gRPC server
- `google.golang.org/protobuf` β Manages protocol buffers
- `github.com/improbable-eng/grpc-web` β Enables gRPC-Web support
- `github.com/gofrs/uuid/v5` β Generates unique IDs
- `github.com/golang-jwt/jwt/v4` β Handles authentication
- `gorm.io/gorm` & `gorm.io/driver/postgres` β Database ORM and PostgreSQL driver
## Setup and Installation
### 1. Clone the Repository
```sh
git clone https://github.com/SebastianBaiju/angular-go-grpc-protocol.git
```
### 2. Install Dependencies
#### Angular
```sh
cd angular-gRPC
npm install
```
#### Go
```sh
cd go-gRPC
go mod tidy
```
### 3. Compile Proto Files
#### Angular
```sh
npm run proto:generate
```
#### Go
```sh
cd proto
make all
```
### 4. Run the Project
#### Start Angular Application
```sh
ng serve
```
#### Start Go Server
```sh
go run main.go
```
## Environment Configuration
### Go (`.env` file)
```
PORT=8080
JWT_SECRET=SECRET
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=postgres
DB_PASSWORD=PASSWORD
DB_NAME=postgres
```
### Angular (`env.js`)
```js
(function(window) {
window.__env = window.__env || {};
window.__env.baseUrl = 'http://localhost:8080';
}(this));
```
## Docker
```sh
docker pull sebu5683/grpc-go-angular:latest
```
## Resources
- [gRPC Go Quickstart](https://grpc.io/docs/languages/go/quickstart/)
- [GORM Documentation](https://gorm.io/index.html)
- [ngx-grpc GitHub](https://github.com/smnbbrv/ngx-grpc)
- [Docker](https://hub.docker.com/repository/docker/sebu5683/grpc-go-angular/tags)
- [Demo Url](https://grpc-go-angular.sebastianbaiju.com/)
- username: admin
- password: admin
## Inspiration
This project is inspired by [grpc-template](https://github.com/Jerinji2016/grpc-template). Contributions are welcomeβletβs build something great together! π