Skip to content

Commit

Permalink
Chess game Mini App for Telegram Contest
Browse files Browse the repository at this point in the history
[@ChessContestBot](https://t.me/ChessContestBot) is a Mini App designed to offer a multiplayer chess gaming experience. Users have the option to choose their side and create a new game, after which they can share the provided game link with their opponent. When the opponent joins the game, the user will receive notifications from the bot regarding the game's progress. Every Telegram user with access to the game link can view the ongoing competition in real-time.
  • Loading branch information
pkozlov committed Oct 10, 2023
1 parent 09c105d commit 7940a22
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,23 @@ Also we have working `Dockerfile` with frontend and backend images.

You can find configuration in `.helm` folder and `werf.yaml` file.

Set environment for Kubernetes config, like ``
1. Set environment for Kubernetes config, like `WERF_KUBECONFIG_BASE64`.
2. Generate `WERF_SECRET_KEY` and configure secret values in `.helm/secret-values.yaml`
3. Provide `REACT_APP_BOT_URI` env variable
4. Just run `werf converge` to deploy to Kubernetes cluster

This configuration uses [Zalando Postgres Operator](https://github.com/zalando/postgres-operator) for database.

For more information, refer to the [werf official documentation](https://werf.io/documentation/v1.2/).

## Imlementation details

For chess logic used [Chess.js](https://github.com/jhlywa/chess.js) library
For chess board used [react-chessboard](https://github.com/Clariity/react-chessboard)
For telegram Web App react bindins user [react-telegram-web-app](https://github.com/vkruglikov/react-telegram-web-app)
For telegram bot server used [Telegraf](https://github.com/telegraf/telegraf)
For database connection and migrations used [Drizzle ORM](https://orm.drizzle.team)
For websockets used [Socket.IO](https://socket.io)

## TODO

Expand Down
5 changes: 4 additions & 1 deletion drizzle.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ export default {
out: "./migrations",
driver: 'pg',
dbCredentials: {
connectionString: `postgres://${process.env.DB_USER || "postgres"}:${process.env.DB_PASS}@${process.env.DB_HOST || "localhost"}:${process.env.DB_PORT || "5432"}/${process.env.DB_NAME || "chess"}${process.env.DB_SSLMODE ? '?sslmode=require' : ''}`
connectionString: `postgres://${process.env.DB_USER || "postgres"}:${process.env.DB_PASS}@${process.env.DB_HOST || "localhost"}:${process.env.DB_PORT || "5432"}/${process.env.DB_NAME || "chess"}${process.env.DB_SSLMODE ? '?sslmode=require' : ''}`,
ssl: process.env.DB_SSLMODE ? {
rejectUnauthorized: false
} : false
}
} satisfies Config;
5 changes: 4 additions & 1 deletion src/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import * as schema from './schema';
const { Client } = pg;

const client = new Client({
connectionString: `postgres://${process.env.DB_USER || "postgres"}:${process.env.DB_PASS}@${process.env.DB_HOST || "localhost"}:${process.env.DB_PORT || "5432"}/${process.env.DB_NAME || "chess"}${process.env.DB_SSLMODE ? '?sslmode=require' : ''}`
connectionString: `postgres://${process.env.DB_USER || "postgres"}:${process.env.DB_PASS}@${process.env.DB_HOST || "localhost"}:${process.env.DB_PORT || "5432"}/${process.env.DB_NAME || "chess"}${process.env.DB_SSLMODE ? '?sslmode=require' : ''}`,
ssl: process.env.DB_SSLMODE ? {
rejectUnauthorized: false
} : false
});

const db = drizzle(client, { schema });
Expand Down

0 comments on commit 7940a22

Please sign in to comment.