Skip to content
This repository was archived by the owner on Dec 1, 2026. It is now read-only.

Commit 437db0d

Browse files
authored
Merge pull request #15 from OctoconDev/atlas-dev
feat(bot): Merge new features from dev branch
2 parents c87d876 + 122e38c commit 437db0d

157 files changed

Lines changed: 3685 additions & 1922 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.credo.exs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
{Credo.Check.Refactor.CondStatements, []},
125125
# {Credo.Check.Refactor.CyclomaticComplexity, [priority: :low]},
126126
{Credo.Check.Refactor.FunctionArity, []},
127-
{Credo.Check.Refactor.LongQuoteBlocks, []},
127+
# {Credo.Check.Refactor.LongQuoteBlocks, []},
128128
{Credo.Check.Refactor.MatchInCondition, []},
129129
{Credo.Check.Refactor.MapJoin, []},
130130
{Credo.Check.Refactor.NegatedConditionsInUnless, []},

‎LICENSE.txt‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Octocon, LLC
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎README.md‎

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,60 @@ This repository contains the backend code for Octocon, which is structured into
1212
- **octocon-web**: The Phoenix web application that serves the REST API, metrics, and admin dashboard.
1313
- **octocon-discord**: The Discord bot that serves as an alternative interface for interacting with the Octocon platform, including "proxying" as alters.
1414

15-
## Distributed monolith
15+
## Development setup
16+
17+
To set up a development environment for Octocon, you'll need to have the following prerequisites installed on a Unix-like operating system or WSL:
18+
- [Docker](https://www.docker.com/get-started)
19+
- [Docker Compose](https://docs.docker.com/compose/install/)
20+
- Git
21+
22+
Once installed, follow these steps to set up your development environment:
23+
1. Clone the repository:
24+
```bash
25+
git clone
26+
cd octocon
27+
```
28+
29+
2. Run the provided setup script:
30+
```bash
31+
./dev/setup.sh
32+
```
33+
This script will ensure your system is configured correctly, build the necessary Docker images, install dependencies, and perform database migrations.
34+
35+
3. Start the development environment:
36+
```bash
37+
./dev/bin/iex
38+
```
39+
This command will launch an interactive Elixir shell running the Octocon application inside a Docker container.
40+
41+
## Contributing
42+
43+
We welcome contributions to Octocon! If you'd like to contribute, please follow these steps:
44+
1. Fork the repository on GitHub and create a new branch for your feature or bug fix.
45+
2. Use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) for your commit messages.
46+
3. Run `mix format` then `mix lint` before submitting a PR to ensure code quality.
47+
4. Submit a pull request to this repository for review.
48+
49+
While we respect your time, please note that not every contribution will be accepted; certain features may not align with our project's goals or privacy/security standards. If you'd like to contribute a new feature, your best bet is to reach out to us in the `#development` channel on our [Discord server](https://discord.gg/octocon) first to discuss its feasibility. Alternatively, we welcome PRs implementing accepted suggestions posted on [our issue tracker](https://github.com/octocondev/issues/issues?q=is%3Aissue%20state%3Aopen%20type%3ASuggestion%20(label%3A%22Low%20Priority%22%20OR%20label%3A%22High%20Priority%22%20OR%20label%3AUrgent))
50+
51+
## Deployment structure
1652
Octocon is designed as a distributed monolith, meaning that while the components have a clear separation of concerns, they share a common codebase which is compiled and deployed as one executable.
1753

18-
Octocon is generally run in a cluster of nodes, which are designed to be globally distributed across the world. One "primary region" interfaces with a larger database instance and runs the Discord bot, while "auxiliary regions" interface with database replicas. This allows for low-latency access to the data from anywhere in the world.
54+
Octocon is generally run in a cluster of nodes, which are designed to be globally distributed across the world. One "primary" node interfaces with a generally larger database instance and runs the Discord bot, while "auxiliary" nodes interface with smaller database instances. This allows for low-latency access to the data from anywhere in the world.
1955

2056
When not running on Fly.io, an Octocon node knows its role in the overall cluster through an environment variable (`NODE_GROUP`), which determines which parts of the supervision tree it will run, and how it will advertise itself to its peers.
2157

22-
By default, Octocon is configured to discover other nodes using the [libcluster](https://github.com/bitwalker/libcluster) library with a custom Tailscale strategy. All that is necessary is for each node to form a Distributed Erlang cluster; Octocon has internal logic to determine and cache each node's role in the cluster through an RPC communication step.
58+
In production, Octocon is configured to discover other nodes using the [libcluster](https://github.com/bitwalker/libcluster) library with a custom Tailscale strategy. All that is necessary is for each node to form a Distributed Erlang cluster; Octocon has internal logic to determine and cache each node's role in the cluster through an RPC communication step.
2359

2460
There are 3 node groups:
25-
- `primary`: A node running in the primary region, which interfaces with the read-write database and runs Discord shards. Other nodes proxy their database writes to a `primary` node.
26-
- `auxiliary`: A node running in an auxiliary region, which interfaces with a read-only replica of the database. These nodes are largely only responsible for serving HTTP requests to the API.
27-
- `sidecar`: A node responsible for isolating CPU-bound tasks from the rest of the cluster, such as image processing and heavy encryption tasks. **At least one** sidecar must be present in the entire cluster.
61+
- `primary`: A node running in the primary region, which interfaces with a larger database instance, runs Discord shards, and handles certain types of global state. Other nodes proxy some requests to a `primary` node.
62+
- `auxiliary`: A node running in an auxiliary region, which interfaces with a smaller database instance. These nodes are largely only responsible for serving HTTP requests to the API.
63+
- `sidecar`: A node responsible for isolating CPU-bound tasks from the rest of the cluster, such as image processing and heavy encryption tasks. Ideally, **at least one** sidecar should be present in the cluster. If no sidecar is present, nodes will run these tasks themselves.
2864

2965
**Note**: Running multiple `primary` nodes is heavily experimental and not currently recommended - our Discord library (Nostrum) still doesn't behave well in this type of distributed environment.
66+
3067
## Configuration & integrations
68+
3169
Every Octocon node must be configured with a set of environment variables to function properly. These variables are used to connect to the database, configure the Discord bot, and set up other integrations, such as cloud object storage.
3270

3371
### OAuth
@@ -65,4 +103,7 @@ Every Octocon node must be configured with a set of environment variables to fun
65103
- `NODE_GROUP` - The group this node belongs to (`primary`, `auxiliary`, or `sidecar`).
66104
- `PRIMARY_NODE_COUNT` - Number of primary nodes in the cluster (**values other than 1 are experimental**).
67105
- `POOL_SIZE` - Size of the database connection pool.
68-
- `PORT` - Port to run the Phoenix web server on.
106+
- `PORT` - Port to run the Phoenix web server on.
107+
- `TAILSCALE_API_AUTHKEY` - When present, enables Tailscale-based clustering using the provided auth key.
108+
- `NODE_LIST` - When present, enables static clustering with the provided comma-separated list of node IPs.
109+
If neither `TAILSCALE_API_AUTHKEY` nor `NODE_LIST` are present, a single-node cluster is assumed, which will run as a `primary` node.

‎config/config.exs‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ config :logger, :console,
3636
format: "$time $metadata[$level] $message\n",
3737
metadata: [:request_id]
3838

39-
config :logger,
40-
backends: [:console, Sentry.LoggerBackend]
39+
config :octocon, :logger, [
40+
{:handler, :sentry_handler, Sentry.LoggerHandler,
41+
%{
42+
config: %{metadata: [:file, :line]}
43+
}}
44+
]
4145

4246
# Use Jason for JSON parsing in Phoenix
4347
config :phoenix, :json_library, Jason
@@ -117,7 +121,7 @@ config :nostrum,
117121
:direct_message_reactions,
118122
:message_content
119123
],
120-
# TODO: Manual sharding
124+
# [TODO]: Manual sharding
121125
# num_shards: :manual,
122126
ffmpeg: false,
123127
gateway_compression: :zstd

‎config/prod.exs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ config :octocon, :nostrum_scope, :global
44

55
config :mnesia, dir: ~c"/mnesia"
66

7-
# TODO: Do not print debug messages in production
7+
# [TODO]: Do not print debug messages in production
88
config :logger, level: :info
99

1010
config :sentry,

‎config/runtime.exs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ if config_env() == :prod do
7373
config :octocon, :node_group, node_group
7474
config :octocon, :current_db_region, current_db_region
7575

76-
# TODO: Only :auxiliary
77-
# TODO: Rename :auxiliary to :ingress
76+
# [TODO]: Only :auxiliary
77+
# [TODO]: Rename :auxiliary to :ingress
7878
if node_group in [:primary, :auxiliary] || System.get_env("PHX_SERVER") do
7979
config :octocon, OctoconWeb.Endpoint, server: true
8080
else

‎docker-compose.dev.yml‎

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@ services:
44
ports:
55
- "9042:9042"
66
restart: always
7-
command: --seeds=scylla-nam --smp 1 --memory 750M --overprovisioned 1 --developer-mode 1
7+
command: --seeds=172.18.1.1,172.18.1.2 --smp 1 --memory 750M --overprovisioned 1 --developer-mode 1 --api-address 0.0.0.0 --broadcast-address scylla-nam
88
volumes:
99
- ./dev/scylla/cassandra-rackdc.nam.properties:/etc/scylla/cassandra-rackdc.properties
1010
- ./dev/scylla/data/nam:/var/lib/scylla
1111
- ./dev/scylla/scylla.yaml:/etc/scylla/scylla.yaml
1212
networks:
1313
octo_network:
14+
ipv4_address: 172.18.1.1
1415

1516
scylla-eur:
1617
image: scylladb/scylla:2025.1
1718
restart: always
18-
command: --seeds=scylla-nam,scylla-eur --smp 1 --memory 750M --overprovisioned 1 --developer-mode 1
19+
command: --seeds=172.18.1.1,172.18.1.2 --smp 1 --memory 750M --overprovisioned 1 --developer-mode 1 --api-address 0.0.0.0 --broadcast-address scylla-eur
1920
volumes:
2021
- ./dev/scylla/cassandra-rackdc.eur.properties:/etc/scylla/cassandra-rackdc.properties
2122
- ./dev/scylla/data/eur:/var/lib/scylla
@@ -24,81 +25,67 @@ services:
2425
- scylla-nam
2526
networks:
2627
octo_network:
27-
28-
scylla-gdpr:
29-
image: scylladb/scylla:2025.1
30-
restart: always
31-
command: --seeds=scylla-nam,scylla-eur --smp 1 --memory 750M --overprovisioned 1 --developer-mode 1
32-
volumes:
33-
- ./dev/scylla/cassandra-rackdc.gdpr.properties:/etc/scylla/cassandra-rackdc.properties
34-
- ./dev/scylla/data/gdpr:/var/lib/scylla
35-
- ./dev/scylla/scylla.yaml:/etc/scylla/scylla.yaml
36-
depends_on:
37-
- scylla-nam
38-
- scylla-eur
39-
networks:
40-
octo_network:
28+
ipv4_address: 172.18.1.2
4129

4230
scylla-sam:
4331
image: scylladb/scylla:2025.1
4432
restart: always
45-
command: --seeds=scylla-nam,scylla-eur --smp 1 --memory 750M --overprovisioned 1 --developer-mode 1
33+
command: --seeds=172.18.1.1,172.18.1.2 --smp 1 --memory 750M --overprovisioned 1 --developer-mode 1 --api-address 0.0.0.0 --broadcast-address scylla-sam
4634
volumes:
4735
- ./dev/scylla/cassandra-rackdc.sam.properties:/etc/scylla/cassandra-rackdc.properties
4836
- ./dev/scylla/data/sam:/var/lib/scylla
4937
- ./dev/scylla/scylla.yaml:/etc/scylla/scylla.yaml
5038
depends_on:
5139
- scylla-nam
5240
- scylla-eur
53-
- scylla-gdpr
5441
networks:
5542
octo_network:
43+
ipv4_address: 172.18.1.3
5644

5745
scylla-sas:
5846
image: scylladb/scylla:2025.1
5947
restart: always
60-
command: --seeds=scylla-nam,scylla-eur --smp 1 --memory 750M --overprovisioned 1 --developer-mode 1
48+
command: --seeds=172.18.1.1,172.18.1.2 --smp 1 --memory 750M --overprovisioned 1 --developer-mode 1 --api-address 0.0.0.0 --broadcast-address scylla-sas
6149
volumes:
6250
- ./dev/scylla/cassandra-rackdc.sas.properties:/etc/scylla/cassandra-rackdc.properties
6351
- ./dev/scylla/data/sas:/var/lib/scylla
6452
- ./dev/scylla/scylla.yaml:/etc/scylla/scylla.yaml
6553
depends_on:
6654
- scylla-nam
6755
- scylla-eur
68-
- scylla-gdpr
6956
- scylla-sam
7057
networks:
7158
octo_network:
59+
ipv4_address: 172.18.1.4
7260

7361
scylla-eas:
7462
image: scylladb/scylla:2025.1
7563
restart: always
76-
command: --seeds=scylla-nam,scylla-eur --smp 1 --memory 750M --overprovisioned 1 --developer-mode 1
64+
command: --seeds=172.18.1.1,172.18.1.2 --smp 1 --memory 750M --overprovisioned 1 --developer-mode 1 --api-address 0.0.0.0 --broadcast-address scylla-eas
7765
volumes:
7866
- ./dev/scylla/cassandra-rackdc.eas.properties:/etc/scylla/cassandra-rackdc.properties
7967
- ./dev/scylla/data/eas:/var/lib/scylla
8068
- ./dev/scylla/scylla.yaml:/etc/scylla/scylla.yaml
8169
depends_on:
8270
- scylla-nam
8371
- scylla-eur
84-
- scylla-gdpr
8572
- scylla-sam
8673
- scylla-sas
8774
networks:
8875
octo_network:
76+
ipv4_address: 172.18.1.5
8977

9078
scylla-ocn:
9179
image: scylladb/scylla:2025.1
9280
restart: always
93-
command: --seeds=scylla-nam,scylla-eur --smp 1 --memory 750M --overprovisioned 1 --developer-mode 1
81+
command: --seeds=172.18.1.1,172.18.1.2 --smp 1 --memory 750M --overprovisioned 1 --developer-mode 1 --api-address 0.0.0.0 --broadcast-address scylla-ocn
9482
volumes:
9583
- ./dev/scylla/cassandra-rackdc.ocn.properties:/etc/scylla/cassandra-rackdc.properties
9684
- ./dev/scylla/data/ocn:/var/lib/scylla
9785
- ./dev/scylla/scylla.yaml:/etc/scylla/scylla.yaml
9886
depends_on:
9987
- scylla-nam
10088
- scylla-eur
101-
- scylla-gdpr
10289
- scylla-sam
10390
- scylla-sas
10491
- scylla-eas
@@ -109,6 +96,7 @@ services:
10996
retries: 20
11097
networks:
11198
octo_network:
99+
ipv4_address: 172.18.1.6
112100

113101
scylla-load-keyspaces:
114102
image: scylladb/scylla:2025.1
@@ -152,6 +140,7 @@ services:
152140
- app_build:/build
153141
- app_deps:/deps
154142
- .:/app
143+
user: root
155144
depends_on:
156145
scylla-ocn:
157146
condition: service_healthy
@@ -161,6 +150,10 @@ services:
161150
networks:
162151
octo_network:
163152
driver: bridge
153+
ipam:
154+
driver: default
155+
config:
156+
- subnet: 172.18.0.0/16
164157

165158
volumes:
166159
app_build:

‎lib/nosedrum/converters/role.ex‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ defmodule Nosedrum.Converters.Role do
100100
find_role(Map.values(guild.roles), text, ilike)
101101

102102
{:error, _reason} ->
103-
case Api.get_guild_roles(guild_id) do
103+
case Api.Guild.roles(guild_id) do
104104
{:ok, roles} ->
105105
find_role(roles, text, ilike)
106106

‎lib/nosedrum/storage.ex‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ defmodule Nosedrum.Storage do
183183
}
184184

185185
Nostrum.Api.create_interaction_response(interaction, res)
186+
|> IO.inspect()
186187
end
187188

188189
@doc """
@@ -209,7 +210,7 @@ defmodule Nosedrum.Storage do
209210
|> Keyword.take([:content, :embeds, :components, :allowed_mentions])
210211
|> Map.new()
211212

212-
Nostrum.Api.edit_interaction_response(interaction, data)
213+
Nostrum.Api.Interaction.edit_response(interaction, data)
213214
end
214215

215216
defp convert_callback_type({type, _fn}) do

‎lib/nosedrum/storage/dispatcher.ex‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ defmodule Nosedrum.Storage.Dispatcher do
103103
build_payload(p, c)
104104
end)
105105

106-
case Nostrum.Api.bulk_overwrite_global_application_commands(command_list) do
106+
case Nostrum.Api.ApplicationCommand.bulk_overwrite_global_commands(command_list) do
107107
{:ok, _} = response ->
108108
{:reply, response, commands}
109109

@@ -118,7 +118,7 @@ defmodule Nosedrum.Storage.Dispatcher do
118118
build_payload(p, c)
119119
end)
120120

121-
case Nostrum.Api.bulk_overwrite_guild_application_commands(guild_id, command_list) do
121+
case Nostrum.Api.ApplicationCommand.bulk_overwrite_guild_commands(guild_id, command_list) do
122122
{:ok, _} = response ->
123123
{:reply, response, commands}
124124

@@ -134,7 +134,7 @@ defmodule Nosedrum.Storage.Dispatcher do
134134

135135
@impl true
136136
def handle_call({:add, payload, name, command, :global}, _from, commands) do
137-
case Nostrum.Api.create_global_application_command(payload) do
137+
case Nostrum.Api.ApplicationCommand.create_global_command(payload) do
138138
{:ok, _} = response ->
139139
{:reply, response, Map.put(commands, name, command)}
140140

@@ -148,7 +148,7 @@ defmodule Nosedrum.Storage.Dispatcher do
148148
when is_list(guild_id_list) do
149149
res =
150150
Enum.reduce(guild_id_list, {[], []}, fn guild_id, {errors, responses} ->
151-
case Nostrum.Api.create_guild_application_command(guild_id, payload) do
151+
case Nostrum.Api.ApplicationCommand.create_guild_command(guild_id, payload) do
152152
{:ok, _} = response ->
153153
{errors, [response | responses]}
154154

@@ -162,7 +162,7 @@ defmodule Nosedrum.Storage.Dispatcher do
162162

163163
@impl true
164164
def handle_call({:add, payload, name, command, guild_id}, _from, commands) do
165-
case Nostrum.Api.create_guild_application_command(guild_id, payload) do
165+
case Nostrum.Api.ApplicationCommand.create_guild_command(guild_id, payload) do
166166
{:ok, _} = response ->
167167
{:reply, response, Map.put(commands, name, command)}
168168

@@ -173,7 +173,7 @@ defmodule Nosedrum.Storage.Dispatcher do
173173

174174
@impl true
175175
def handle_call({:remove, name, command_id, :global}, _from, commands) do
176-
case Nostrum.Api.delete_global_application_command(command_id) do
176+
case Nostrum.Api.ApplicationCommand.delete_global_command(command_id) do
177177
{:ok} = response ->
178178
{:reply, response, Map.delete(commands, name)}
179179

@@ -187,7 +187,7 @@ defmodule Nosedrum.Storage.Dispatcher do
187187
when is_list(guild_id_list) do
188188
res =
189189
Enum.reduce(guild_id_list, {[], []}, fn guild_id, {errors, responses} ->
190-
case Nostrum.Api.delete_guild_application_command(guild_id, command_id) do
190+
case Nostrum.Api.ApplicationCommand.delete_guild_command(guild_id, command_id) do
191191
{:ok} ->
192192
{errors, [:ok | responses]}
193193

@@ -201,7 +201,7 @@ defmodule Nosedrum.Storage.Dispatcher do
201201

202202
@impl true
203203
def handle_call({:remove, name, command_id, guild_id}, _from, commands) do
204-
case Nostrum.Api.delete_guild_application_command(guild_id, command_id) do
204+
case Nostrum.Api.ApplicationCommand.delete_guild_command(guild_id, command_id) do
205205
{:ok} = response ->
206206
{:reply, response, Map.delete(commands, name)}
207207

0 commit comments

Comments
 (0)