Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sentrionic/Valkyrie
A Fullstack Discord Clone using React and Go.
https://github.com/sentrionic/Valkyrie
chakra-ui discord gin-gonic go gorilla-websocket nestjs react realtime socket-io typescript websockets
Last synced: 9 days ago
JSON representation
A Fullstack Discord Clone using React and Go.
- Host: GitHub
- URL: https://github.com/sentrionic/Valkyrie
- Owner: sentrionic
- License: mit
- Created: 2021-02-26T14:54:04.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-26T11:40:55.000Z (over 1 year ago)
- Last Synced: 2024-10-12T17:21:10.363Z (about 1 month ago)
- Topics: chakra-ui, discord, gin-gonic, go, gorilla-websocket, nestjs, react, realtime, socket-io, typescript, websockets
- Language: Go
- Homepage:
- Size: 76 MB
- Stars: 302
- Watchers: 12
- Forks: 69
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Go Report Card](https://goreportcard.com/badge/github.com/sentrionic/Valkyrie)](https://goreportcard.com/report/github.com/sentrionic/Valkyrie)
# Valkyrie
A [Discord](https://discord.com) clone using [React](https://reactjs.org/) and [Go](https://golang.org/).
**Notes:**
- The design does not fully match the current design of Discord anymore.
- For the old [Socket.io](https://socket.io/) stack using [NestJS](https://nestjs.com/) check out the [v1](https://github.com/sentrionic/Valkyrie/tree/v1) branch.## Video
https://user-images.githubusercontent.com/38354571/137365365-a7fe91d6-51d7-4739-8742-f68517223f8f.mp4
## Features
- Message, Channel, Server CRUD
- Authentication using Express Sessions
- Channel / Websocket Member Protection
- Realtime Events
- File Upload (Avatar, Icon, Messages) to S3
- Direct Messaging
- Private Channels
- Friend System
- Notification System
- Basic Moderation for the guild owner (delete messages, kick & ban members)
- Basic Voice Chat (one voice channel per guild + mute & deafen)## Stack
### Server
- [Gin](https://gin-gonic.com/) for the HTTP server
- [Gorilla Websockets](https://github.com/gorilla/websocket) for WS communication
- [Gorm](https://gorm.io/) as the database ORM
- PostgreSQL to save all data
- Redis for storing sessions and reset tokens
- S3 for storing files and Gmail for sending emails### Web
- React with [Chakra UI](https://chakra-ui.com/)
- [React Query](https://react-query.tanstack.com/) & [Zustand](https://github.com/pmndrs/zustand) for state management
- [Typescript](https://www.typescriptlang.org/)For the mobile app using Flutter check out [ValkyrieApp](https://github.com/sentrionic/ValkyrieApp)
---
## Installation
### Server
If you are familiar with `make`, take a look at the `Makefile` to quickly setup the following steps
or alternatively copy the commands into your CLI.1. Install Docker and get the Postgresql and Redis containers (`make postgres` && `make redis`)
2. Start both containers (`make start`) and create a DB (`make createdb`)
3. Install the latest version of Go and get all the dependencies (`go mod tidy`)
4. Rename `.env.example` to `.env` and fill in the values- `Required`
PORT=4000
DATABASE_URL=postgresql://:@localhost:5432/valkyrie
REDIS_URL=redis://localhost:6379
CORS_ORIGIN=http://localhost:3000
SECRET=SUPERSECRET
HANDLER_TIMEOUT=5
MAX_BODY_BYTES=4194304 # 4MB in Bytes = 4 * 1024 * 1024- `Optional: Not needed to run the app, but you won't be able to upload files or send emails.`
AWS_ACCESS_KEY=ACCESS_KEY
AWS_SECRET_ACCESS_KEY=SECRET_ACCESS_KEY
AWS_STORAGE_BUCKET_NAME=STORAGE_BUCKET_NAME
AWS_S3_REGION=S3_REGION
GMAIL_USER=GMAIL_USER
GMAIL_PASSWORD=GMAIL_PASSWORD5. Run `go run github.com/sentrionic/valkyrie` to run the server
**Alternatively**: If you only want to run the backend without installing Go and all dependencies, you can download the pre compiled server from the [Release tab](https://github.com/sentrionic/Valkyrie/releases) instead. You will still need to follow the above steps 1, 2 and 4.
### Web
1. Install Node 20 or the LTS version of Node.
2. Install [yarn](https://classic.yarnpkg.com/lang/en/)
3. Run `yarn` to install the dependencies
4. Run `yarn start` to start the client
5. Go to `localhost:3000`## Endpoints
Once the server is running go to `localhost:/swagger/index.html` to see all the HTTP endpoints
and `localhost:` for all the websockets events.## Tests
All tests are run on all push and pull requests. Only if they are successful it will run the other Github Actions to automatically deploy the updates.
### Server
All routes in `handler` have tests written for them.
Function calls in the `service` directory that do not just delegate work to the repository have tests written for them.
Run `go test -v -cover ./service/... ./handler/...` (`make test`) to run all tests
Additionally this repository includes E2E tests for all successful requests. To run them you
have to have Postgres and Redis running in Docker and then run `go test github.com/sentrionic/valkyrie` (`make e2e`).### Web
Most `useQuery` hooks have tests written for them.
To run them use `yarn test`.
Additionally [Cypress](https://www.cypress.io/) is used for E2E testing.
To run them you need to have the server and the client running.
After that run `yarn cypress` to open the test window.**Note**: For unkown reasons websockets connection only randomly work during Cypress runs, which makes testing them impossible.
## Credits
[Ben Awad](https://github.com/benawad): The inital project is based on his Slack tutorial series and I always look at his repositories for inspiration.
[Jacob Goodwin](https://github.com/JacobSNGoodwin/memrizr): This backend is built upon his tutorial series and uses his backend structure.
[Jeroen de Kok](https://dev.to/jeroendk/building-a-simple-chat-application-with-websockets-in-go-and-vue-js-gao): The websockets structure is based on his tutorial.
[ericellb](https://github.com/ericellb/React-Discord-Clone): His repository helped me implement voice chat.