{"id":16702113,"url":"https://github.com/farazhaider/futstats","last_synced_at":"2025-07-22T19:05:31.841Z","repository":{"id":68024536,"uuid":"155138051","full_name":"farazhaider/futstats","owner":"farazhaider","description":"Football Stats in Phoenix with a modular architecture","archived":false,"fork":false,"pushed_at":"2018-11-01T08:50:10.000Z","size":237,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-14T06:43:49.012Z","etag":null,"topics":["elixir"],"latest_commit_sha":null,"homepage":"https://farazhaider.github.io/futstats/","language":"Elixir","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/farazhaider.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":"2018-10-29T02:09:34.000Z","updated_at":"2022-12-19T13:57:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"b930aa78-726d-48bc-acd1-7cbb9cceed60","html_url":"https://github.com/farazhaider/futstats","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/farazhaider/futstats","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farazhaider%2Ffutstats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farazhaider%2Ffutstats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farazhaider%2Ffutstats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farazhaider%2Ffutstats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/farazhaider","download_url":"https://codeload.github.com/farazhaider/futstats/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farazhaider%2Ffutstats/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266554326,"owners_count":23947310,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"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":["elixir"],"created_at":"2024-10-12T18:46:50.300Z","updated_at":"2025-07-22T19:05:31.802Z","avatar_url":"https://github.com/farazhaider.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"FutStats\n\n## Architecture\n\nA high level view of the solution is given beow.\n\n![](architecture.png)\n\n## Design\n\nThe application is based on Phoenix Framework which internally uses Plug and Cowboy. So the app is a set of models, controllers and their respective views.\n\nThe API routes have been defined in the `Router.ex` file. Every incoming request to the server goes through a plug pipeline. The response is rendered according to the views associated with each controller. Views are defined in `fut_stats_web/views` while the controllers reside in `fut_stats_web/controllers`. The API is capable of sending `JSON` as well as `protbuf` responses.\n\nThe application uses `ecto` to communicate with a Postgres Database. Ecto supports `schemas` which directly map to database tables. The schema for the football data resides in `fut_stats/models`.\nBefore we can start seeding or querying the database we need to run the migrations. `ecto.migrate` maps a schema to a migration script which is executed to create a database table. The database is seeded using the `seed.exs` script. This process is done inside a separate ephemeral container called a seeder to keep the architecture simple.\n\nLogging and Metrics are done using Elixir's native logger and the `Instruments` package. `StatsD` is used for the collection of the time series metrics data. In `Application.ex`, several important probes have been defined to measure `Beam` performance and resource usage. API response times and request rates are calculated by a custom plug `Plugs.Metrics`. Ecto query performance measured by a custom ecto logger `Repo.Metrics` which writes the query count and response times to the StatsD server.\n\nSwagger has been used as the way to document the HTTP APIs and ex_doc has been used to make the documentation\n\n\n## Running the Application\n\nThe application comes bundled with a `.Dockerfile` and a `docker-compose.yml` file for easier deployments.\n\nMake sure you have `Docker` and `Docker Compose` installed.\n\nInitialize a Docker swarm on your machine if you haven't so already.\n\n`docker swarm init`\n\n(In case if the command prompts you for specifying an IP run `docker-machine ls` and input the default IP)\n\n Then execute the following command to run a shell script. (Make sure it is executable, if not run `chmod +x run.sh`)\n\n`./run.sh`\n\nThis script does the following\n\n- delete any existing host volumes for the docker-compose.yml and create new ones\n- delete any existing stack with the name `futstat`\n- build the docker-compose.yml\n- deploy a stack named `futstat` using the docker-compose.yml\n\nThese steps are only required the first time you are deploying the stack, in the subsequent turns you could just do the deploy stack step and it would work fine. And feel free to map the host ports to different one's if any of them are occupied by existing services.\n\nYou may have to wait for a few seconds until all the containers have successfully started.(The seeder service seeds the database with the test data)\n\n- The FutStats API would be live at `http://\u003cHost-Address\u003e/api/`\n- Graphite console at `http://\u003cHost-Address\u003e:3100`\n- Grafana console at `http://\u003cHost-Address\u003e:3000`\n- Swagger API console at `http://\u003cHost-Address\u003e/swagger/`\n\nHost-Address could be `localhost` if running locally or an external IP if running in a cloud VM.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarazhaider%2Ffutstats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffarazhaider%2Ffutstats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarazhaider%2Ffutstats/lists"}