{"id":22529431,"url":"https://github.com/minhtran241/flexiconnect-architecture","last_synced_at":"2026-03-04T21:32:24.457Z","repository":{"id":154023354,"uuid":"550002080","full_name":"minhtran241/flexiconnect-architecture","owner":"minhtran241","description":"FlexiConnect Architecture is a distributed system designed with versatile data transport options, providing flexibility and efficiency in handling diverse data sources and destinations.","archived":false,"fork":false,"pushed_at":"2022-10-17T20:30:08.000Z","size":157415,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-23T15:56:04.469Z","etag":null,"topics":["amqp","bootstrap","caddy","docker","docker-hub","docker-swarm","gnu-make","golang","grpc","mailhog","microservices","mongodb","postgresql","protocol-buffers","rabbitmq","rpc"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/minhtran241.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2022-10-12T03:53:49.000Z","updated_at":"2024-06-20T16:03:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"d89a33a5-29e2-4e0a-ad12-07f0907ac03d","html_url":"https://github.com/minhtran241/flexiconnect-architecture","commit_stats":null,"previous_names":["minhtran241/flexiconnect-architecture"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/minhtran241/flexiconnect-architecture","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minhtran241%2Fflexiconnect-architecture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minhtran241%2Fflexiconnect-architecture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minhtran241%2Fflexiconnect-architecture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minhtran241%2Fflexiconnect-architecture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/minhtran241","download_url":"https://codeload.github.com/minhtran241/flexiconnect-architecture/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minhtran241%2Fflexiconnect-architecture/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30093799,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T20:42:30.420Z","status":"ssl_error","status_checked_at":"2026-03-04T20:42:30.057Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["amqp","bootstrap","caddy","docker","docker-hub","docker-swarm","gnu-make","golang","grpc","mailhog","microservices","mongodb","postgresql","protocol-buffers","rabbitmq","rpc"],"created_at":"2024-12-07T07:14:42.497Z","updated_at":"2026-03-04T21:32:24.438Z","avatar_url":"https://github.com/minhtran241.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Microservices with Go\n\nThe Microservices Architecture contains\n\n-   Broker Service\n-   Authentication Service\n-   Logger Service\n-   Mail Service\n-   Listener Service AMQP with RabbitMQ\n\n## GNU Make\n\n-   [www.gnu.org/software/make](https://www.gnu.org/software/make/) is a tool which controls the generation of executables and other non-source files of a program from the program's source files\n-   Make gets its knowledge of how to build your program from a file called the `makefile`, which lists each of the non-source files and how to compute it from other files. When you write a program, you should write a makefile for it, so that it is possible to use Make to build and install the program\n-   All the `Docker` images control for\n\n    -   `Linux/MacOS` are in the `project/Makefile` file\n    -   `Windows` are in the `project/Makefile.windows` file\n\n## Frontend Test\n\n-   The Test Page is used for test the Services in this Architecture\n-   The Test Page will send an example request to the specific Service that user choose and then receive the response from that Service\n-   Technologies\n    -   [bootstrap](https://getbootstrap.com/docs/5.2/getting-started/introduction/)\n    -   [javaScript](https://www.javascript.com) for fetching data from the services\n    -   [html](https://developer.mozilla.org/en-US/docs/Learn/HTML)\n\n## Broker Service\n\n-   \u003cstrong\u003eBroker Service\u003c/strong\u003e is an entry point for redirecting the request to appropriate service and receiving the response from that service\n-   Package index\n    -   [github.com/go-chi/chi](https://github.com/go-chi/chi) is a lightweight, idiomatic and composable router for building `Go` HTTP services\n        -   Installation\n            ```sh\n            go get github.com/go-chi/chi/v5\n            go get github.com/go-chi/chi/middleware\n            go get github.com/go-chi/cors\n            ```\n    -   [pkg.go.dev/net/rpc](https://pkg.go.dev/net/rpc) provides access to the exported methods of an object across a network or other I/O connection. A server registers an object, making it visible as a service with the name of the type of the object. After registration, exported methods of the object will be accessible remotely. A server may register multiple objects (services) of different types but it is an error to register multiple objects of the same type\n-   File `broker-service/broker-service.dockerfile` is the `dockerfile` for the service\n\n## Authentication Service with PostgreSQL\n\n-   \u003cstrong\u003eAuthentication Service\u003c/strong\u003e is an API for determining if the credentials from the request body is matching the data in the database. All the credentials are stored in a PostgreSQL image\n-   Package index\n    -   [github.com/go-chi/chi](https://github.com/go-chi/chi) is a lightweight, idiomatic and composable router for building `Go` HTTP services\n        -   Installation\n            ```sh\n            go get github.com/go-chi/chi/v5\n            go get github.com/go-chi/chi/middleware\n            go get github.com/go-chi/cors\n            ```\n    -   [github.com/jackc/pgconn](https://github.com/jackc/pgconn) is a low-level `PostgreSQL` database driver. It operates at nearly the same level as the `C` library `libpq`\n        -   Installation\n            ```sh\n            go get github.com/jackc/pgconn\n            ```\n    -   [github.com/jackc/pgx](https://github.com/jackc/pgx) is a higher level libraries, high performance interface that exposes PostgreSQL-specific features such as `LISTEN` / `NOTIFY` and `COPY`. It also includes an adapter for the standard `database/sql` interface. The toolkit component is a related set of packages that implement `PostgreSQL` functionality such as parsing the wire protocol and type mapping between `PostgreSQL` and `Go`\n        -   Installation\n            ```sh\n            go get github.com/jackc/pgx/v4\n            go get github.com/jackc/pgx/v4/stdlib\n            ```\n    -   [github.com/golang/crypto/bcrypt](https://github.com/golang/crypto/blob/master/bcrypt/bcrypt.go) is used for hashing passwords\n    -   [pkg.go.dev/database/sql](https://pkg.go.dev/database/sql) provides a generic interface around SQL (or SQL-like) databases. The sql package must be used in conjunction with a database driver. See [golang.org/s/sqldrivers](https://golang.org/s/sqldrivers) for a list of drivers\n-   File `authentication-service/authentication-service.dockerfile` is the `dockerfile` for the service\n\n## Logger Service with MongoDB\n\n-   \u003cstrong\u003eLogger Service\u003c/strong\u003e is an API for saving logs whenever one Service receives and processes a response. All the `LogEntry` struct contains 2 fields Name and Data. The collections are stored in a MongoDB image\n-   Package index\n    -   [github.com/go-chi/chi](https://github.com/go-chi/chi) is a lightweight, idiomatic and composable router for building `Go` HTTP services\n        -   Installation\n            ```sh\n            go get github.com/go-chi/chi/v5\n            go get github.com/go-chi/chi/middleware\n            go get github.com/go-chi/cors\n            ```\n    -   [github.com/mongodb/mongo-go-driver](https://github.com/mongodb/mongo-go-driver) is the `MongoDB` supported driver for `Go`\n        -   Installation\n            ```sh\n            go get go.mongodb.org/mongo-driver/mongo\n            go get go.mongodb.org/mongo-driver/mongo/options\n            ```\n    -   [pkg.go.dev/net/rpc](https://pkg.go.dev/net/rpc) provides access to the exported methods of an object across a network or other I/O connection. A server registers an object, making it visible as a service with the name of the type of the object. After registration, exported methods of the object will be accessible remotely. A server may register multiple objects (services) of different types but it is an error to register multiple objects of the same type.\n-   File `logger-service/logger-service.dockerfile` is the `dockerfile` for the service\n\n## Mail Service\n\n-   \u003cstrong\u003eMail Service\u003c/strong\u003e connects directly with \u003cstrong\u003eBroker Service\u003c/strong\u003e in the development version which you shouldn't do in production. In production, \u003cstrong\u003eMail Service\u003c/strong\u003e can not be connected by User, just be connected to other Service except Broker Service. The Service sends tested mails to the MailHog server\n-   Package index\n    -   [github.com/go-chi/chi](https://github.com/go-chi/chi) is a lightweight, idiomatic and composable router for building `Go` HTTP services\n        -   Installation\n            ```sh\n            go get github.com/go-chi/chi/v5\n            go get github.com/go-chi/chi/middleware\n            go get github.com/go-chi/cors\n            ```\n    -   [github.com/mailhog/MailHog](https://github.com/mailhog/MailHog) is an email testing tool for developers\n        -   Overview\n            -   Configure your application to use `MailHog` for SMTP delivery\n            -   View messages in the web UI, or retrieve them with the JSON API\n            -   Optionally release messages to real SMTP servers for delivery\n        -   Installation\n            ```sh\n            go get github.com/mailhog/MailHog\n            ```\n        -   The local server of `MailHog` runs on `http://localhost:1025`, check this server for web UI and see all the tested mails in the `Inbox` section\n        -   A `Docker` image for `MailHog` is configured in file `project/docker-compose.yml`\n    -   [github.com/vanng822/go-premailer](github.com/vanng822/go-premailer) is an inline styling for HTML mail in `Go`\n        -   Styling mail with both `HTML` and `plain` formats before sending\n        -   Installation\n            ```sh\n            go get github.com/vanng822/go-premailer/premailer\n            ```\n    -   [github.com/xhit/go-simple-mail](https://github.com/xhit/go-simple-mail) is the best way to send emails in `Go` with SMTP Keep Alive and Timeout for Connect and Send\n        -   You can find more information in the [documentation](https://pkg.go.dev/github.com/xhit/go-simple-mail/v2)\n        -   Installation\n            ```sh\n            go get github.com/xhit/go-simple-mail/v2\n            ```\n-   File `mail-service/mail-service.dockerfile` is the `dockerfile` for the service\n\n## Listener Service AMQP\n\n-   \u003cstrong\u003eListener Service AMQP\u003c/strong\u003e listens for any data (requests) pushed to RabbitMQ server to consume it as soon as possible\n-   Any requests after being routed by \u003cstrong\u003eBroker Service\u003c/strong\u003e is pushed directly to RabbitMQ server. The \u003cstrong\u003eListener Service AMQP\u003c/strong\u003e connects to the RabbitMQ server and listens to any requests in the message queue and then sends requests to the appropriate Services\n-   Package index\n    -   [github.com/rabbitmq/amqp091-go](https://github.com/rabbitmq/amqp091-go) is a `Go AMQP 0.9.1` client maintained by the [RabbitMQ core team](https://github.com/rabbitmq). The package provides a functional interface that closely represents the `AMQP 0.9.1` model targeted to `RabbitMQ` as a server\n        -   Installation\n            ```sh\n            go get github.com/rabbitmq/amqp091-go\n            ```\n-   File `listener-service/listener-service.dockerfile` is the `dockerfile` for the service\n\n## RabbitMQ Server\n\n-   The \u003cstrong\u003efirst option\u003c/strong\u003e for \u003cstrong\u003eBroker Service\u003c/strong\u003e to communicate with \u003cstrong\u003eLogger Service\u003c/strong\u003e\n    -   `logEventViaRabbit(w http.ResponseWriter, l LogPayload)` just pushes requests from the client to the `RabbitMQ` Server for \u003cstrong\u003eListener Service\u003c/strong\u003e to consume\n-   Image for the `RabbitMQ` server is [`rabbitmq:3.9-alpine`](https://github.com/docker-library/rabbitmq/blob/6889979f517c7ea3a7bd54bb88864dc8c29d327c/3.9/alpine/Dockerfile), runs on port `5672` on `docker` server\n-   Uses the `topics` as exchange type\n-   Does not delete data until it is consumed successfully\n-   References\n    -   Find more information about `RabbitMQ` at [RabbitMQ website](https://www.rabbitmq.com)\n    -   [Godoc API reference](https://pkg.go.dev/github.com/rabbitmq/amqp091-go)\n    -   [RabbitMQ tutorials in Go](https://github.com/rabbitmq/rabbitmq-tutorials/tree/main/go)\n\n## Communicating between Services using RPC\n\n-   The \u003cstrong\u003esecond option\u003c/strong\u003e for \u003cstrong\u003eBroker Service\u003c/strong\u003e to communicate with \u003cstrong\u003eLogger Service\u003c/strong\u003e\n    -   `logItemViaRPC(w http.ResponseWriter, l LogPayload)` connects to the `RPC` Server of \u003cstrong\u003eLogger Service\u003c/strong\u003e on port `5001` and calls the function of the `RPC` Server using [pkg.go.dev/net/rpc](https://pkg.go.dev/net/rpc) package\n        -   When it comes to the `RPC` option, the \u003cstrong\u003eLogger Service\u003c/strong\u003e has to always listen to the `RPC` requests\n        -   \u003cstrong\u003eBroker Service\u003c/strong\u003e and \u003cstrong\u003eLogger Service\u003c/strong\u003e use [pkg.go.dev/net/rpc](https://pkg.go.dev/net/rpc) package to communicate. The \u003cstrong\u003eBroker Service\u003c/strong\u003e is the client and the \u003cstrong\u003eLogger Service\u003c/strong\u003e is the server\n\n## gRPC Connection\n\n-   The \u003cstrong\u003ethird option\u003c/strong\u003e for \u003cstrong\u003eBroker Service\u003c/strong\u003e to communicate with \u003cstrong\u003eLogger Service\u003c/strong\u003e\n    -   `LogViaGRPC(w http.ResponseWriter, r *http.Request)` creates a client and connects the client to the `gRPC` server that is located in the `logger-service/cmd/api/grpc.go` file. the gRPC server runs on port `50001`\n-   Information about packages and how to work and generate codes with `Protocol Buffers` and `gRPC`\n    -   [My Protocol Buffers Instruction repo](https://github.com/minhtran241/protocol_buffers_go_generate)\n    -   [My gRPC Introduction repo](https://github.com/minhtran241/gRPC-introduction)\n\n## Docker usage\n\n-   All the `Docker` configurations are in the `project/docker-compose.yml` file\n\n-   Build all the `Docker` images and services's binaries\n    ```sh\n    make up-build\n    ```\n-   Build one `Docker` image of one specific service\n    ```sh\n    make service-build\n    ```\n-   Pull and Start all the `Docker` images\n    ```sh\n    make up\n    ```\n-   Stop docker compose\n    ```sh\n    make down\n    ```\n-   Start the `frontend` binary listening on `http://localhost:80`\n    ```sh\n    make start\n    ```\n-   Stop the `frontend` binary listening on `http://localhost:80`\n    ```sh\n    make stop\n    ```\n\n## Deployment\n\n-   Docker Swarm\n\n    -   Build images for microservice\n        ```sh\n        docker build -f servicename.dockerfile -t your_docker_hub_username/servicename:1.0.0 .\n        ```\n    -   Push images to `docker hub`\n        ```sh\n        docker push your_docker_hub_username/servicename:1.0.0\n        ```\n    -   Configurations of `Docker Swarm` are in `project/swarm.yml` file\n    -   Go to the `project` folder\n    -   Initiate `Swarm` (set the manager node is the `project` folder)\n        ```sh\n        docker swarm init\n        ```\n    -   In order to set the current folder as the `manager/worker` node\n        ```sh\n        docker swarm join-token manager/worker\n        ```\n    -   Create all the services following the configurations of `Docker Swarm`\n        ```sh\n        docker stack deploy -c swarm.yml go-microservices\n        ```\n    -   List the running services\n        ```sh\n        docker service ls\n        ```\n    -   Scaling services\n        ```sh\n        docker service scale go-microservices_servicename=number_of_tasks\n        ```\n    -   If one service suddenly dies, `Docker Swarm` will create another instance and bring it back up\n\n-   Updating Services\n    -   Build a new tagged version of the service\n        ```sh\n        docker build -f servicename.dockerfile -t your_docker_hub_username/servicename:1.0.1 .\n        ```\n    -   Push images again to `docker hub`\n        ```sh\n        docker push your_docker_hub_username/servicename:1.0.1\n        ```\n    -   Update the version of the service currently running in `Swarm`\n        -   Any time updating a service to a new version, at least 2 tasks of that service have to be running in order to achieve no downtime\n            ```sh\n            docker service scale go-microservices_servicename=2\n            ```\n        -   Update one image to a new version\n            ```sh\n            docker service update --image your_docker_hub_username/servicename:1.0.1 go-microservices_servicename\n            ```\n        -   Downgrade\n            ```sh\n            docker service update --image your_docker_hub_username/servicename:1.0.0 go-microservices_servicename\n            ```\n-   Stopping Docker Swarm\n    ```sh\n    docker service scale go-microservices_servicename=0\n    ```\n-   Removing Docker Swarm\n    ```sh\n    docker stack rm go-microservices\n    ```\n-   Leaving Docker Swarm (use `--force` on a node that is participating as manager)\n    ```sh\n    docker swarm leave\n    ```\n-   Caddy\n    -   Added to the mix as a Proxy to the Front end and the Broker\n    -   Configurations in the `project/Caddyfile` file\n    -   Build the `caddy` docker image\n        ```sh\n        docker build -f caddy.dockerfile -t your_docker_hub_username/micro-caddy:1.0.0 .\n        docker push your_docker_hub_username/micro-caddy:1.0.0\n        ```\n-   Bringing up Swarm\n    ```sh\n    docker stack deploy -c swarm.yml go-microservices\n    ```\n\n## Contributor\n\n-   Minh Tran (Me)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminhtran241%2Fflexiconnect-architecture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fminhtran241%2Fflexiconnect-architecture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminhtran241%2Fflexiconnect-architecture/lists"}