Example of interoperability between a Web App and a Discord Bot using a layered architecture.
Important
dsGO
is still in the early stages of development.
go install github.com/bastean/dsgo/cmd/dsgo@latest
Note
- We can follow this guide "Building your first Discord app" to create a new app in case we do not have one already created.
- SQLite will be used as the default database instead of MySQL.
dsgo -h
Usage: dsgo [OPTIONS]
Example of interoperability between a Web App and a Discord Bot using a layered architecture.
-app string
Discord App Id Token (required)
-database string
SQLite database file path (default "In-Memory")
-guild string
Discord Test Guild Id (optional)
-port string
Fiber Server Port (optional)
-token string
Discord Bot Token (required)
Note
- System Requirements
- We must define our own Discord configuration in the file .env.demo by modifying the variables
DSGO_BOT_DISCORD_*
.- The required values are
DSGO_BOT_DISCORD_APP_ID
andDSGO_BOT_DISCORD_APP_TOKEN
, the other values are optional. - We can follow this guide "Building your first Discord app" to create a new app in case we do not have one already created.
- The required values are
- MySQL will be used as the default database, SQLite will only be used in case there is a connection problem with MySQL.
make demo
It is a simple monolith where CRUD operations are performed from the Web App and the Discord Bot to the same database, this allows us to manage users from different applications (presentations).
-
pkg/context
- It is the logical core that contains all the necessary functionalities that are independent of any presentation (application).
-
internal/pkg/service
- It is responsible for initializing all “context” functionalities so that they are ready for use, as well as for “mapping” certain values to centralize all imports of presentations (applications) in a single place.
-
internal/app/(bot|server)
- These applications will be used as “presentations” in order to serve the functionalities to an end user.
git clone https://github.com/bastean/dsgo.git && cd dsgo
git clone git@github.com:bastean/dsgo.git && cd dsgo
-
System Requirements
-
Start VS Code
code .
-
Open Command Palette
- Ctrl+Shift+P
-
Run
Dev Containers: Reopen in Container
-
Run
make init-zero
Important
Before running it, we must initialize the following environment variable files:
- .env.example
- We will have to create a
.env.(dev|test|prod)
for each runtime environment. - In the .env.example.demo file, we can see the values that can be used.
- We will have to create a
In case we only want to run the Integration or Acceptance tests, in addition to having the .env.test
file, we must have the following files created:
- .env.example.test.integration
- Rename the file to
.env.test.integration
.
- Rename the file to
- .env.example.test.acceptance
- Rename the file to
.env.test.acceptance
.
- Rename the file to
make compose-dev
make test-unit
make compose-test-integration
make compose-test-acceptance
make compose-tests
make compose-prod
- Contributions and Feedback are always welcome!