{"id":26702103,"url":"https://github.com/leoantony72/twitter-backend","last_synced_at":"2025-04-13T11:27:41.316Z","repository":{"id":65855023,"uuid":"584055812","full_name":"leoantony72/twitter-backend","owner":"leoantony72","description":"backend clone of Twitter with golang","archived":false,"fork":false,"pushed_at":"2024-07-30T06:07:57.000Z","size":1680,"stargazers_count":173,"open_issues_count":2,"forks_count":23,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-27T02:39:10.533Z","etag":null,"topics":["api","authentication","golang","jwt","jwt-authentication","postgresql","rabbitmq","redis","twitter"],"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/leoantony72.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":"2023-01-01T05:51:44.000Z","updated_at":"2025-03-23T13:14:42.000Z","dependencies_parsed_at":"2025-03-27T02:37:25.807Z","dependency_job_id":"2bd0ac2f-2913-46b5-b41f-030c5787d0dc","html_url":"https://github.com/leoantony72/twitter-backend","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/leoantony72%2Ftwitter-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoantony72%2Ftwitter-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoantony72%2Ftwitter-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoantony72%2Ftwitter-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leoantony72","download_url":"https://codeload.github.com/leoantony72/twitter-backend/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248705011,"owners_count":21148469,"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":["api","authentication","golang","jwt","jwt-authentication","postgresql","rabbitmq","redis","twitter"],"created_at":"2025-03-27T02:33:43.873Z","updated_at":"2025-04-13T11:27:41.280Z","avatar_url":"https://github.com/leoantony72.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Twitter Backend API\n\nThis is a Twitter-Backend side project written in Golang along with\ndatabase like PostgreSQL and Redis, and RabbitMQ as message Queue.\n\n[Article explaining the internals:](https://medium.com/@leoantony102/how-i-made-twitter-back-end-57addbaa14f5)\n\n# Docker Build\n\n```bash\ndocker network create Twitter\n```\n\n```bash\ndocker-compose up -d\n```\n\n\u003cb\u003eOnly the logs of services are outputed rest are disabled in docker-compose file\u003c/b\u003e\n\n# Authentication\n\nThis API uses JWT (JSON Web Tokens) for authentication. When a user logs in, the API generates a JWT containing the user's id, which is used to authenticate all subsequent requests. I have usen Asymmetric\nJWTs so it have an private and a public key. private key will be used for creating tokens and public key will be used for verifying the tokens. The Public key is shared by other service for authentication.\n\n![Asymmetric JWT key](img/slave_jwt_key.png)\n\n# Endpoints\n\n## Auth\n\n\u0026nbsp;\n\n### Routes:\n\n\u0026nbsp;\n\n| Method | Url                 | Description               |\n| ------ | ------------------- | ------------------------- |\n| POST   | /auth/signup        | Creates a new user.       |\n| POST   | /auth/login         | Login a user              |\n| POST   | /auth/logout        | Logout a user             |\n| POST   | /auth/refresh-token | Generate new access Token |\n\n## User\n\n\u0026nbsp;\n\n### Routes:\n\n\u0026nbsp;\n\n| Method | Url                      | Description       |\n| ------ | ------------------------ | ----------------- |\n| GET    | /user/data/:username     | Gets User Details |\n| DELETE | /                        | Delete User       |\n| UPDATE | /                        | Update User       |\n| POST   | /user/follow?username=   | Follows User      |\n| POST   | /user/unfollow?username= | Unfollows User    |\n\n## Tweet\n\n\u0026nbsp;\n\n### Routes:\n\n\u0026nbsp;\n\n| Method | Url                   | Description           |\n| ------ | --------------------- | --------------------- |\n| POST   | /tweet/create         | Create Tweet          |\n| GET    | /tweet/id/:id         | Get Tweet By ID       |\n| DELETE | /tweet/id/:id/delete  | Del Tweet by ID       |\n| POST   | /tweet/id/:id/like    | Like a Tweet by ID    |\n| POST   | /tweet/id/:id/dislike | DisLike a Tweet by ID |\n| POST   | /tweet/id/:id/retweet | Retweet a tweet       |\n| DELETE | /tweet/id/:id/retweet | del a Retweet         |\n\n## Timeline\n\n\u0026nbsp;\n\n### Routes:\n\n\u0026nbsp;\n\n| Method | Url                             | Description                               |\n| ------ | ------------------------------- | ----------------------------------------- |\n| GET    | /timeline/home?start=           | Gets User's Home timeline                 |\n| GET    | /timeline/user?username=\u0026start= | Gets User Timeline by specifying username |\n\n# Architecture\n\nAs you know this project in microservice architecture, So each service is independent.\nTweet service and Timeline service is connected through Message Queue (RabbitMq). Tweet Service sends the new tweets to Timeline Service and Timleine service pushes these to respective tweet authors followers timeline If authors follower count is less than 10(I know it's very low but for testing this is fine). If it's above 10 followers would fetch tweet when they load the timeline.\n\n![Tweet-Timleine link by Mq](img/tweet-timeline.png)\n\n\u0026nbsp;\n\n# Conclusion\n\nThis was a fun project, I'm glad I could finish this project😬 learned some new things like How twitter timeline works, consul(service register), HAproxy(load balancer), RabbitMq(Message Queue) and Asymmetric JWT token. Now going back to learning👋.\n\nTwitter Journey: \"https://twitter.com/serpico_z/status/1605899167439757312\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleoantony72%2Ftwitter-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleoantony72%2Ftwitter-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleoantony72%2Ftwitter-backend/lists"}