{"id":15470757,"url":"https://github.com/comtihon/social_network_example","last_synced_at":"2025-07-08T08:03:34.777Z","repository":{"id":143127173,"uuid":"91250010","full_name":"comtihon/social_network_example","owner":"comtihon","description":"Social Network and Chat project example (Erlang)","archived":false,"fork":false,"pushed_at":"2017-05-14T14:47:13.000Z","size":19,"stargazers_count":5,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-22T12:12:13.253Z","etag":null,"topics":["code-structure","erlang","erlang-developement","patterns","refactoring"],"latest_commit_sha":null,"homepage":"","language":"Erlang","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/comtihon.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":"2017-05-14T14:45:57.000Z","updated_at":"2021-11-12T12:09:45.000Z","dependencies_parsed_at":"2023-06-05T23:45:45.745Z","dependency_job_id":null,"html_url":"https://github.com/comtihon/social_network_example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/comtihon/social_network_example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comtihon%2Fsocial_network_example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comtihon%2Fsocial_network_example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comtihon%2Fsocial_network_example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comtihon%2Fsocial_network_example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/comtihon","download_url":"https://codeload.github.com/comtihon/social_network_example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comtihon%2Fsocial_network_example/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264229194,"owners_count":23576235,"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":["code-structure","erlang","erlang-developement","patterns","refactoring"],"created_at":"2024-10-02T02:06:37.668Z","updated_at":"2025-07-08T08:03:34.723Z","avatar_url":"https://github.com/comtihon.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Social Network and Chat project example (Erlang)\nThis is a skeleton of a backend for a social network and chat for\nmobile applications.  \nIt's purposed for:\n- to show Erlang developers, that storing code modules in separate\nsub-directories is a good;\n- show no-Erlang developers, that Erlang can be used in writing\ncomplex applications;\n- to show [Erlang code structural\npatterns](https://justtech.blog/2017/05/14/erlang-structural-patterns/)\nin action;\n\nIt is a simplified skeleton of a real-world chat and social network application. Many export functions and modules,\nwhich can tell something about its business logic were removed.\n\n## Code organization\n__/include__ for all headers, which are used in many modules. Although some Erlang programmers like to keep their\n headers files in `src` it is not recommended. In big projects `src` is used for sources and `include` is used for \n headers. Don't mess them out.  \n__/src__ is used for source code. Here all modules are stored in subdirectories (like packages in Java/Python). Although\n some Erlang programmers throw their source code modules to `src`, like a trash - it is not recommended. Divide and rule.  \n__/test__ is used for test code. Here `test/unit` contains unit tests, `test/functional` are functional tests based on \ncommon test framework, and `test/full` is full integration tests with emulation sending packages to handlers. Although \nsome Erlang programmers mess out test code and production code - it is not recommended: `test` is for tests, `src` is \nfor production code.\n\n## Patterns\n__Application__ is covered in `src/main/sn_test_app.erl`. It is small and simple.  \n__Otp Process__ (gen_server) is covered in `src/daemons/sn_conf_holder`. Although it is only a template, created by Idea,\n without any real code.  \n__Supervisor__ (static) is covered in `src/main/sn_top_sup` and `src/sn_daemons_sup`.  \n__Interface__ is covered in `src/business/auth/`. There `sn_auth_intf` is and interface module with implementations in\n the same packages. Interface implementations nearly always should be in the same package or subpackages. The only \n exception is to expose an interface for outside usage in a library (like `gen_server` or `cowboy_websocket` behaviors).  \n__Manager__ can be frequently meet all other the project. You can check `src/business/friends/sn_friends_mngr` as an \nexample.  \n__Logic__ is also frequently used nearly everywhere. As an example of masking logic pattern you can see \n`src/business/friends/invite/sn_contacts_logics.erl`. It contains an implementation of functions re-exported by a \nmanager. These are the majority of logic modules in this project. Another logic pattern is shared code - it can be seen \nin `src/business/auth/sn_auth_logic.erl`. It shares common functions, which are called from interface implementations.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomtihon%2Fsocial_network_example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcomtihon%2Fsocial_network_example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomtihon%2Fsocial_network_example/lists"}