Skip to the content.

shop-telegram-bot

Shop in telegram with admin panel

Technology stack

Java 17, Maven, Spring 3 (Boot, MVC, Data, Security), Hibernate, Postgresql, Freemarker, HTML, Telegram Bots

Notes before deploy

How to deploy with docker

mvn -f shop-telegram-bot/admin-panel/ package
mvn -f shop-telegram-bot/telegram-bot/ package

docker build -t shop-admin-panel shop-telegram-bot/admin-panel/
docker build -t shop-telegram-bot shop-telegram-bot/telegram-bot/

docker-compose -f shop-telegram-bot/docker-compose.yml up -d

How to deploy manually

  1. Install software
  1. Set environment variables

Add database environment variables.

Or you can manually change configuration in properties telegram-bot/src/main/resources/hibernate.cfg.xml and admin-panel/src/main/resources/application.properties

  1. Create telegram bot
  1. Set up database

Replace your-directory with directory where the cloned repository is located

  1. Set up admin panel
Create systemd unit Replace `your-directory` with directory where the cloned repository is located `nano /etc/systemd/system/shop-admin-panel.service` ``` [Unit] Description=shop-admin-panel After=syslog.target [Service] WorkingDirectory=/your-directory/shop-telegram-bot/ ExecStart=/usr/bin/java -jar /your-directory/shop-telegram-bot/admin-panel/target/admin-panel-1.0.0.jar StandardOutput=journal StandardError=journal SyslogIdentifier=shop-admin-panel SuccessExitStatus=143 Type=simple Restart=always [Install] WantedBy=multi-user.target reboot.target default.target poweroff.target ``` `systemctl daemon-reload` `systemctl enable shop-admin-panel.service` `systemctl start shop-admin-panel.service`
Nginx configuration Replace `your-domain.com` with your domain (domain is needed for correct sending of product photos) `nano /etc/nginx/conf.d/your-domain.com.conf` ``` server { listen 80; server_name your-domain.com; index index.html; include conf.d/shop-admin-panel.include; } ``` `nano /etc/nginx/conf.d/shop-admin-panel.include` ``` location /admin { proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 1024m; } ``` `systemctl restart nginx`

Web UI is accessible on http://localhost:8080/admin, default credentials - admin:admin

  1. Set up telegram bot
Create systemd unit Replace `your-directory` with directory where the cloned repository is located `nano /etc/systemd/system/shop-telegram-bot.service` ``` [Unit] Description=shop-telegram-bot After=syslog.target [Service] WorkingDirectory=/your-directory/shop-telegram-bot/ ExecStart=/usr/bin/java -jar /your-directory/shop-telegram-bot/telegram-bot/target/telegram-bot-1.0.0-jar-with-dependencies.jar StandardOutput=journal StandardError=journal SyslogIdentifier=shop-telegram-bot SuccessExitStatus=143 Type=simple Restart=always [Install] WantedBy=multi-user.target reboot.target default.target poweroff.target ``` `systemctl daemon-reload` `systemctl enable shop-telegram-bot.service` `systemctl start shop-telegram-bot.service`

Screenshots

Chatbot

Admin panel