{"id":15292314,"url":"https://github.com/ebosas/microservices","last_synced_at":"2025-04-09T20:07:17.544Z","repository":{"id":56800724,"uuid":"372718382","full_name":"ebosas/microservices","owner":"ebosas","description":"A microservices example in Go","archived":false,"fork":false,"pushed_at":"2021-12-02T12:42:36.000Z","size":1712,"stargazers_count":306,"open_issues_count":0,"forks_count":36,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-09T20:07:12.368Z","etag":null,"topics":["aws","ci-cd","docker","go","microservices","postgresql","rabbitmq","reactjs","redis","websocket"],"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/ebosas.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}},"created_at":"2021-06-01T06:03:48.000Z","updated_at":"2024-11-24T22:36:43.000Z","dependencies_parsed_at":"2022-08-17T01:30:28.045Z","dependency_job_id":null,"html_url":"https://github.com/ebosas/microservices","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ebosas%2Fmicroservices","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ebosas%2Fmicroservices/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ebosas%2Fmicroservices/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ebosas%2Fmicroservices/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ebosas","download_url":"https://codeload.github.com/ebosas/microservices/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103872,"owners_count":21048245,"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":["aws","ci-cd","docker","go","microservices","postgresql","rabbitmq","reactjs","redis","websocket"],"created_at":"2024-09-30T16:17:20.471Z","updated_at":"2025-04-09T20:07:17.514Z","avatar_url":"https://github.com/ebosas.png","language":"Go","readme":"# Microservices\n\nA basic example of a microservice architecture.\n\n* Written in Go\n* Uses RabbitMQ to communicate between services\n* Uses WebSocket to talk to the front end\n* Stores data in PostgreSQL\n* Stores cache in Redis\n* Uses React for front end development\n* Builds with Docker\n* Deployed on AWS with CI/CD\n\n![](demo.gif)\n\n## Local use\n\nTo run the example locally, clone the Github repository and start the services using Docker Compose. Once Docker finishes downloading and building the images, the front end is accessible by visiting `localhost:8080`.\n\n```bash\ngit clone https://github.com/ebosas/microservices\ncd microservices\n```\n```bash\ndocker-compose up\n```\n\n## Deploy to Amazon ECS/AWS Fargate\n\nFrom the `deployments` directory, create the pipeline stack. It will provision all the resources (network, cluster, etc.) and create a pipeline for each service. At this point, we have yet to build our service images.\n\n```bash\naws cloudformation deploy \\\n    --stack-name Microservices \\\n    --template-file pipeline.yml \\\n    --parameter-overrides \\\n        EnvironmentName=msprod \\\n        LaunchType=Fargate \\\n        GitHubRepo=\u003cgithub_repo_name\u003e \\\n        GitHubBranch=\u003cgithub_branch\u003e \\\n        GitHubToken=\u003cgithub_token\u003e \\\n        GitHubUser=\u003cgithub_user\u003e \\\n    --capabilities CAPABILITY_NAMED_IAM\n```\n\nTo build and deploy all services, push some changes to your repository with `[BuildAll]` added to the message. To trigger specific services, add `[BuildServer]`, `[BuildCache]`, or `[BuildDatabase]`.\n\nOnce finished, visit the URL of the load balancer. It is available in the LoadBalancer's Outputs tab in CloudFormation.\n\n### Github repo setup\n\nFork or otherwise copy this repo to your Github account.\n\nOn the [Github access token page](https://github.com/settings/tokens), generate a new token with the following access:\n\n* `repo`\n* `admin:repo_hook`\n\n### Deleting stacks\n\nDelete stacks in reverse order in CloudFormation. The artifact bucket and ECR repositories need to be deleted manually. So as the auto scaling group (from the EC2 console) when using the EC2 launch type.\n\n## Local resources\n\nWhen running locally, inspect resources by launching relevant Docker containers.\n\n\u003cdetails\u003e\n  \u003csummary\u003eSee details\u003c/summary\u003e\n\n### Database\n\nTo access the database, launch a new container that will connect to our Postgres database. Then enter the password `demopsw` (see the `.env` file).\n\n```bash\ndocker run -it --rm \\\n    --network microservices_network \\\n    postgres:13-alpine \\\n    psql -h postgres -U postgres -d microservices\n```\n\nSelect everything from the messages table:\n\n```sql\nselect * from messages;\n```\n\n### Redis\n\nTo inspect Redis, connect to its container via redis-cli.\n\n```bash\ndocker run -it --rm \\\n    --network microservices_network \\\n    redis:6-alpine \\\n    redis-cli -h redis\n```\n\nGet all cached messages or show the number of total messages.\n\n```bash\nlrange messages 0 -1\nget total\n```\n\n### RabbitMQ\n\nAccess the RabbitMQ management interface by visiting `localhost:15672` with `guest` as both username and password.\n\n### Back end\n\nTo access the back end service, attach to its docker container from a separate terminal window. Messages from the front end will show up here. Also, standart input will be sent to the front end for two way communication.\n\n```bash\ndocker attach microservices_backend\n```\n\u003c/details\u003e\n\n## Local development\n\nFor development, run the RabbitMQ and Postgres containers with Docker Compose.\n\n\u003cdetails\u003e\n  \u003csummary\u003eSee details\u003c/summary\u003e\n\n```bash\ndocker-compose -f docker-compose-dev.yml up\n```\n\nGenerate static web assets for the server service by going to `web/react` and `web/bootstrap` and running:\n\n```bash\nnpm run build-server\n```\n\n### React\n\nFor React development, run `npm run serve` in `web/react` and change the script tag in the server's template to the following:\n\n```html\n\u003cscript src=\"http://127.0.0.1:8000/index.js\"\u003e\u003c/script\u003e\n```\n\u003c/details\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Febosas%2Fmicroservices","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Febosas%2Fmicroservices","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Febosas%2Fmicroservices/lists"}