@hack.near [Posted on DevHub](https://near.social/#/devgovgigs.near/widget/Post?id=1302) ## Solution: BOSHACKS Submission: Groups For #boshacks, we built a “groups” feature, aiming to provide a reusable `group` type for things, helping everyone create, modify, and use custom social graphs in their applications. Read the [idea](https://near.social/#/devgovgigs.near/widget/gigs-board.pages.Post?id=1083) posted on DevHub for additional context.  ### CONCEPTS **Graphs** represent networks, made of nodes (accounts) and edges (relationships). **Groups** are lists of accounts (and / or things) with specific IDs and relationships among them. ### OBJECTIVE → develop a support system for communities and groups focused on specific topics or initiatives ##### REFERENCES * [Idea: Groups on near.org | RFC](https://near.social/devgovgigs.near/widget/gigs-board.pages.Post?id=1042) by @gauthamravi.near * [Specification with Open Discussion](https://github.com/near/near-discovery/discussions/342) by @charleslavon.near ### STRATEGY We designed the `group` data schema to be a type of graph, so it is open, flexible, and composable. The non-linear, directed graph model helps by distinguishing mutual relationships from one-way connections. It offers a useful approach to validating members of any group. This way, people manage their own connections. Anyone could validate membership of any group, forming the basis for webs of trust. **Example:** when you follow someone, it is different from when they follow you. Plus, there is a unique case when you both follow each other. Such common, mutual graphs represent membership in groups. Rather than submitting a “New Member” proposal to a Sputnik DAO, users can request to be added to a group by adding themselves to their own version of that group. Effectively, that means creating a graph with the same ID. Each group and its “sibling” have the same ID, which anyone may use to save their own version of that group’s members. Such alternative instances of the group are maintained by anyone who interacts with a certain graph in the Near Social database (on-chain) as a root node, such as @every.near in this example of 1 group for everyone: > every.near/thing/one ### QUESTION Why should the IDs of things be randomly generated vs. human-readable? When these graphs come with randomly generated IDs, the path looks like this: > hack.near/graph/526fb256e74eelmf0nw3n5909bc189c13d/** → much less chance of a collision than usage of human-readable IDs like “one” or “bos” > every.near/graph/one/** Still, groups with human-readable IDs might have a purpose, as the common ground for building community groups. The first account to make a group named “community” is not necessarily the de facto “root node” of the “*/graph/community” thing. On the blockchain operating system, everything can be duplicated and edited, so anyone could maintain their own versions of that “community” graph. Ultimately, counting how many accounts included someone in that group would reflect which people are most frequently attested as a member of the community. Essentially, if you want people to make lots of competitive versions of the graph, consider going with a human-readable ID, and if you don’t want or need other versions of your own group, then use a random UUID. ### SUMMARY We built a creator / editor, discovery page, templates (card, info, page, inline), and a special notification system for groups. Plus, we adapted mob.near’s Follow Button (group.join), FollowersList (group.community), FollowingList (group.contributors), and FollowStats (group.stats). Below are implementation details. **Creating a group:** When we create a group, we generate a random UUID, used in two places: * in the graph (like `follow` or `star`) to store the graph relationships between accounts. * to create a new “Thing” with the same UUID, for adding descriptive info about the group. We index it as a new thing of type group (every/group), so it appears on the “every.group” page. **Creating another version of the group:** When a user creates their own version of a group, they do not duplicate that group thing or generate a new UUID, they only modify their own graph. #### FEATURES The current implementation enables: * Discovering Groups * Creating and Editing * Joining and Leaving * Adding Members * Approving Requests * Accepting Invitations * Viewing Group Details * Dedicated Social Feed #### WIDGETS * Creator: [group.create](https://github.com/near-everything/bos-workspace/blob/main/apps/groups/widget/group/create.jsx) * Editor: [group.edit](https://github.com/near-everything/bos-workspace/blob/main/apps/groups/widget/group/edit.jsx) * Notifications: [group.index](https://github.com/near-everything/bos-workspace/blob/main/apps/groups/widget/group/index.jsx) * View Group Details * [group.page](https://github.com/near-everything/bos-workspace/blob/main/apps/groups/widget/group/page.jsx) * [group.card](https://github.com/near-everything/bos-workspace/blob/main/apps/groups/widget/group/card.jsx) * [group.info](https://github.com/near-everything/bos-workspace/blob/main/apps/groups/widget/group/info.jsx) * [group.inline](https://github.com/near-everything/bos-workspace/blob/main/apps/groups/widget/group/inline.jsx) * [group.image](https://github.com/near-everything/bos-workspace/blob/main/apps/groups/widget/group/image.jsx) * Join Button: [group.join](https://github.com/near-everything/bos-workspace/blob/main/apps/groups/widget/group/join.jsx) * Membership: [group.members](https://github.com/near-everything/bos-workspace/blob/main/apps/groups/widget/group/members.jsx) * [group.stats](https://near.social/near/widget/ComponentDetailsPage?src=hack.near/widget/group.stats) * [group.contributors](https://near.social/near/widget/ComponentDetailsPage?src=hack.near/widget/group.contributors) * [group.community](https://near.social/near/widget/ComponentDetailsPage?src=hack.near/widget/group.community) ### NEXT MILESTONE ##### Member Roles and Permissions Ability to manage access control in the SocialDB settings will empower group members to customize social feeds, moderate channels, and curate content for better experiences. We’re also exploring ways to visualize interconnected social graphs! Overall, we hope `groups` will evolve to help communities connect, grow, and learn together. Please let us know any feedback. Thanks for hacking with us ☺️ 👭 Teammates: @efiz.near @james.near 🔗 Project Link: https://github.com/near-everything/bos-workspace/tree/main/apps/groups 🎥 Demo Link: https://ipfs.near.social/ipfs/bafybeicuufqdlitmrno3imhkowgssqdyjellzgtggrg7essju45lkq7itm