Giter Site home page Giter Site logo

memowords's Introduction

memowords

The app is available at https://t.me/memowordsbot/app

This is a Telegram mini-app designed to help you memorize English words using a simplified version of the SM2 algorithm for spaced repetition. Words will appear at varying frequencies based on how well you're able to remember them.

See apps/memowords-backend/src/learning/learning.service.ts for details on how the algorithm works.

Setup telegram bot (both for local development and production)

Use BotFather to perform the following steps:

  1. Create a new bot
  2. Create web app
  3. For local development, use https://memobot.dmku.local/ as URL for the app
  4. Setup menu button to open web app. For local development, use https://memobot.dmku.local/

Local development

Prerequisites

Running the bot locally

Since telegram requires to use HTTPS, we need to configure it for local development using Caddy container. The configuration file for Caddy is located in Caddyfile.dev file.

First create a volumes for Caddy and Postgres

docker volume create memowords-caddy-data
docker volume create memowords-pg-data-local

Then run the following command to start Caddy and Postgres containers

docker-compose -f docker-compose.dev.yaml up -d

Run frontend (Mini App)

cd apps/quiz-mini-app
yarn dev

Go to backend directory apps/memowords-backend and create .env file with the following variables:

TELEGRAM_BOT_TOKEN=<your telegram bot token>

Prepare database

cd apps/memowords-backend
yarn schema:sync
yarn migration:up

Run backend

cd apps/memowords-backend
yarn start:dev

Setting up access via HTTPS

Follow the instructions in Caddy documentation to set up certificates for local development.

Then add domain name memobot.dmku.local to your /etc/hosts file or use any local DNS server.

Production

Prerequisites

Running the bot in production

Before running the bot, you need to create a .env file in the root directory of the project. This file should contain the following variables:

TELEGRAM_BOT_TOKEN=<your telegram bot token>
ACCESS_TOKEN_SECRET=<your access token secret>
POSTGRES_PASSWORD=<your postgres password>

Create a volume for the postgres database:

docker volume create memowords-pg-data

Create a network to connect the app and upstanding web server:

docker network create memowords

To run the bot, execute the following command:

docker-compose up -d

Web server

This configuration implies that you have a web server running on the host machine that proxies requests to the bot and terminates TLS. For example, you can use Caddy for this purpose.

Use network memowords to connect your web server to the bot. Bot will be available at http://memowords-entrypoint:3000 inside the network.

With Caddy you can use the following configuration:

<your domain> {
    reverse_proxy memowords-entrypoint:3000
}

And Caddy will automatically generate and renew certificates for your domain using Let's Encrypt.

memowords's People

Contributors

kulakovd avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.