rexemtoxa / tg-bot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This project represents a simple Telegram bot API with a backend for authentication.

Dependencies

To run this project locally, you will need the following dependencies:

Setup Project Locally

  1. Clone the repository:

    git clone git@github.com:rexemtoxa/tg-bot.git
    cd tg-bot
  2. Install the dependencies listed above.

  3. Frontend Setup:

    • Navigate to the frontend folder:
      cd frontend
    • Switch to the correct Node.js version:
      nvm use
    • Install Node.js dependencies:
      npm ci
    • Build the frontend:
      npm run build
  4. Backend Setup:

    • Navigate to the backend folder:
      cd backend
    • Switch to the correct Node.js version:
      nvm use
    • Install Node.js dependencies:
      npm ci
    • Copy the example environment variables file and adjust values if necessary:
      cp .env.example .env
  5. Start the database container:

    make start-dev-env
  6. Enjoy! Do not forget to generate the bot token from the BotFather.

For additional commands, please check the scripts section in the package.json files in both the frontend and backend folders.

CI/CD Process

  • Continuous Integration (CI):

    • Runs tests on PRs and pushes.
    • Executes linters to ensure code quality.
  • Continuous Deployment (CD):

    • After each commit to the main branch, deployment to DigitalOcean starts.
    • The bot is deployed as a separate worker to avoid scaling problems since only one bot with one token can exist at a time.
    • The backend is deployed separately to facilitate scaling.
    • Before each deployment, a migration job attempts to apply migrations to the database instance.
    • If something goes wrong during the build or deployment process, a rollback to the previous version is initiated.

Check the Bot and Web

TODO

  • Cover all backend handlers with types.
  • Generate OpenAPI schema from backend handlers.
  • Validate all requests by JSON schema at runtime.
  • Generate web client from OpenAPI schema.
  • Extract dependencies like DB queries from the backend server to some dependency injection to facilitate testing.
  • Write a few integration tests using Playwright or a similar tool and include these steps in the CI pipeline.
  • Move handling of temp tokens/sessions to Redis.
  • Improve logging.

PS. CI/CD and deployed app were destroyed at 19.05

About


Languages

Language:TypeScript 66.4%Language:Svelte 18.8%Language:CSS 6.4%Language:JavaScript 5.3%Language:Dockerfile 1.8%Language:HTML 0.9%Language:Makefile 0.4%