{"id":20295745,"url":"https://github.com/mrpluto0/douyin","last_synced_at":"2026-05-30T21:31:37.082Z","repository":{"id":158676454,"uuid":"588849905","full_name":"MrPluto0/douyin","owner":"MrPluto0","description":"the implementation of douyin's backend by GO","archived":false,"fork":false,"pushed_at":"2023-02-28T12:11:12.000Z","size":12645,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-14T09:55:33.474Z","etag":null,"topics":["backend","golang"],"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/MrPluto0.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-14T08:17:10.000Z","updated_at":"2023-04-11T16:05:03.000Z","dependencies_parsed_at":"2023-05-01T02:01:56.076Z","dependency_job_id":null,"html_url":"https://github.com/MrPluto0/douyin","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/MrPluto0%2Fdouyin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrPluto0%2Fdouyin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrPluto0%2Fdouyin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrPluto0%2Fdouyin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MrPluto0","download_url":"https://codeload.github.com/MrPluto0/douyin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241794114,"owners_count":20021189,"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":["backend","golang"],"created_at":"2024-11-14T15:35:57.153Z","updated_at":"2026-05-30T21:31:37.068Z","avatar_url":"https://github.com/MrPluto0.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Douyin Project\n\n## Introduction\n\nThis is a backend project about simple-douyin of Bytedance, using `gin` `gorm` and so on.\n\n## APIS\n\n- [x] POST `/douyin/user/login`\n- [x] POST `douyin/user/register`\n- [x] GET `/douyin/user/`\n- [x] GET `/douyin/feed`\n\n## How to develop\n\n### Core\n\nThe core code is in `/app`, which has four parts:\n\n- `controller`: it serves as apis' handlers.\n- `service`: it's main business logic.\n- `models`: it's the database models and functions(`dao`) to operate data.\n- `define`: it's the data structure for each request and response.\n\nFrom top to bottom layers: `Router -\u003e Controller -\u003e Service(define) -\u003e Dao -\u003e Model`\n\n### Database\n\nDatabase is initialized in `/init/database.go`.\n\n#### Mysql\n\nThe main database is `mysql`, storing all persistent data. Its control is integrated in `gorm`.\n\nTips: you can create your datatables in database by `gorm.AutoMigrate(...)`\n\n#### Redis\n\nThe cache database is `redis` in which data react quickly. But it's just used in api `GET /douyin/user`.\n\nYou can run benchmark in `/tests/redis_test.go` to see the performance.\n\n### Config\n\nYou can edit the `config.yaml` to add another setting, and use in project like this:\n\n```go\n// learn how to use viper in go\nviper.Get(\"new_config\")\n```\n\n### Test\n\n#### Feature Test\n\nFor each finished apis, it needs to be tested features in `tests` folder.\n\nFor each utils, it needs to be tested basicly in the same level folder.\n\nThe standards are as follows:\n\n- Test all error code's examples which the apis may response.\n- Write notes above this line or subtest including name to explain this test.\n\n#### Benchmark\n\nFor some modules, you can write benchmark in test files. Such as redis and mysql benchmark.\n\n```bash\ngoos: linux\ngoarch: amd64\npkg: douyin/tests\ncpu: Intel(R) Xeon(R) Platinum 8255C CPU @ 2.50GHz\nBenchmarkRedis\nBenchmarkRedis-4   \t   10000\t    112403 ns/op\t     188 B/op\t       7 allocs/op\nBenchmarkMysql\nBenchmarkMysql-4   \t    3570\t    300697 ns/op\t    9013 B/op\t     134 allocs/op\nPASS\nok  \tdouyin/tests\t2.291s\n```\n\n#### Pressure Test\n\nYou can test the QPS by some tools, such as `ab`/`wrk`/...\n\nThe folder `wrk` is several scripts of `lua`, used to presssure tests.\n\nRun the command in bash: `wrk -t12 -c400 -d10s -T30 -s ./wrk/login.lua http://127.0.0.1:8080`\n\nHere is the result:\n\n```bash\nRunning 10s test @ http://127.0.0.1:8080\n  12 threads and 400 connections\n  Thread Stats   Avg      Stdev     Max   +/- Stdev\n    Latency    45.82ms   19.46ms 229.79ms   80.51%\n    Req/Sec   733.62    134.87     1.19k    81.42%\n  87715 requests in 10.09s, 14.89MB read\nRequests/sec:   8694.54\nTransfer/sec:      1.48MB\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrpluto0%2Fdouyin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrpluto0%2Fdouyin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrpluto0%2Fdouyin/lists"}