Greetings, colleagues. Today we're going to talk about the prep work you need to do before you start coding rampantly. More specifically, about planning, creating an application architecture. But where to start? How to build this architecture? As with everything, you need to start from the beginning. Namely, with IDEAS. The idea of our project was to create a useful telegram bot with basic functionality. Let's repeat exactly how: “I, as a user, want to be able to receive notifications when new articles are published in those groups on CodeGym that interest me.” Following the YAGNI principle, we will build our application. This means that we will only take what we need. We will not create functionality in advance and in reserve just because we want it so much and someday it can really come in handy. Yes, we will create a readable and extensible application, but this does not mean that we will make the database schema “growth”. In order not to support this “growth”, I decided that it would be better to completely abandon it. This will help us avoid unnecessary support during development and unnecessary testing. Later, when our project goes into production (again, anglicism, from the abbreviation prod - production), we will already be able to do something more. Once you have an idea, you need to play around a little.draw. What to draw? We will need the ability to save data on subscriptions to groups of different users. I know that you can use the user ID in the form of a chat ID in the telegram. And there is an idea how the search for new articles will actually take place: we will search in all groups that have subscriptions for new articles and send them to chats. Based on this, we get, as a first approximation, this (here is the development without embellishment):I do not hope that you will understand my handwriting: I want to show exactly how and where development begins. The first stage has been passed: we have somehow decided what will happen. The models/tables in the database are described above. But this is a draft version: it can and should be polished and brought into a more readable form. While grinding, I remembered that I still want to get statistics on the work of the bot. Added this. In this figure, it is more than clear what and how will be arranged. That is, what will be the tables and fields in them, what will be the names of the entities for the tables. It was decided that there will be several of them:
- User - information about the telegram user who will use our bot. As you can see, we save only the chat ID and flag, active user or not. Why? Because our goal is not to collect information about users, but to benefit them;
- GroupSub - there will be information about the group that is subscribed to and the last article that was sent to subscribers;
- Statistics - I didn't create a schema for it - we'll do that later. This is not the main goal in the MVP of the project.
Create a repository for work
Finally, you can create a repository already for working with the telegram bot.- We fill in the items already familiar to us - the name of the repository, its brief description.
- Add a license - Apache 2.0 (you can choose a license at your discretion).
- Our project is now available - here is a link to it: CodeGym Telegrambot .
Create a project in the repository
It would be nice to use GitHub's tools, such as the project, to work with the project. What it is? This is a place within which you can create tasks, track their implementation, save the status of the task. Determine who will perform them and more. To do this, in the created project, we will find the Projects button , and we will already create a new one there: As you can see, here I specified the name of the project, described it and chose the template we will work on - Automated Kanban. For us now it is not so important what it means. The main thing is that we will have a board with tasks, divided into columns, where each of the columns will be the status of the task:- To do - all tasks that are planned to be done;
- In progress — tasks that are being worked on at the moment;
- Done - tasks that have already been done within this project.
We write tasks (issue) for the project
To understand what tasks to write, let's decide what we will have in the project. We need an application that can be run easily and quickly, so that we can access the database, so that we can manage the database schema and change it, so that we can make REST requests in CodeGym to get data on articles. Based on this, you can choose the following technologies:- SpringBoot - as a framework for our application,
- Spring Data - for working with the database,
- Flyway - for working with database migrations,
- MySQL - like a database for a project,
- Telegrambot StringBoot starter - a library for working with a telegram bot,
- Unirest is a library for working with REST requests.
Issue Creation Template
We will create tasks according to the following template:- The task name will look like this: JRTB-{IssueNumber}:{IssueDescription} , where:
- {IssueNumber} is the ordinal number of the issue. We take it one more from the last task;
- {IssueDescription} - a brief description of the issue.
- In the body of the task, we will make a more detailed description of it (sometimes it can coincide with the description in the task name).
- Acceptance Criteria is a list of requirements after which the task can be considered completed. So to speak, the criteria for accepting the task. According to them, the reviewer (from the English reviewer - a reviewer - a person who looks at how the task is completed) can understand whether the task has been completed or not.
- [FEATURE] JRTB-0: create Skeleton Spring boot project - everything is clear here: you need to do the first part of what we did in the previous article.
- [FEATURE] JRTB-2: add telegram bot to the project - we add an empty bot that will simply answer and say that it is alive and well.
- [FEATURE] JRTB-3: Implement Command pattern for telegrambot - let's set up the correct approach to working with commands in a telegram bot. So far for a few teams.
- [FEATURE] JRTB-1: Add repository layer - this is one of the biggest tasks - everything that needs to be done to work with the database is combined here.
- [FEATURE] JRTB-5: As a user, I want to add the group to the subscription - this is the first User Story in the understanding of Agile. Here there will already be a real output for our users: it will be possible to add subscriptions to groups in the bot.
- [FEATURE] JRTB-12: Implement scheduling for sending notification about new articles - here will be the implementation of the search for new articles if they are out for each of the groups and sent to all users who are subscribed to the groups.
- [FEATURE] JRTB-6: As a user, I want to see list of my group subscriptions - everything is simple here: we add a command with a list of all groups to which the user is subscribed.
- [FEATURE] JRTB-7: As a User, I want to remove group subscription from my subscriptions - here you need to implement the removal of a user's subscription to updates in a group.
- [FEATURE] JRTB-8: As a User, I want to set inactive using bot - implement stopping the bot. That is, everything that needs to be done in our system so that the work stops. Add the /stop command to processing.
- [FEATURE] JRTB-9: As a User, I want to start working with bot OR set active if I used it before - add /start command processing. Exactly the way we want it.
- [FEATURE] JRTB-10: As an administrator, I want to see bot statistics - create a collection of bot statistics. Adding admin capability.
- [FEATURE] JRTB-11: As a user, I want to see documentation for this telegram bot - writing documentation. Yes, yes, friends, there is nowhere without it, and the sooner you learn how to do this, the better it will be for you))
Populating the repository
What else needs to be done BEFORE we start coding? - Author, how many of these paragraphs can you add, are you getting them out of the abyss ?? — No, the quality of work is shown in details. And they are the ones that make sense. So let's add one more detail. In order for the project to become popular and understandable for other developers, you need to fill it. What needs to be added? For a complete list of what can be done, I described in the article Optimizing work with your projects on GitHub: getting to know the Github Template Repository . I highly recommend reading. It is important for us to have a clear versioning, a clear understanding of what we are doing. Therefore, I added a RELEASE_NOTES file, which will record changes to our project. As an example, you can look at RELEASE_NOTES from my project(yes, why not show what I put my strength and creativity into). It describes the changes for each new version. I also added templates for creating new tasks, in which there are 4 options:- Bug Report is a task created by users/testers who find a bug in their work. This is a very important thing: it helps to manage error correction;
- A feature request is a task to add new functionality. All the first tasks on the project are tasks on the feature request;
- Improvement request - a task to improve the performance of the application. For example, to change test answers while working with a bot. I'm not a technical writer and can come up with answers that aren't quite right. So if there is a desire and ability - offer :)
- Question is a question for developers about how the application works. A very useful thing. Suppose there is no understanding in the work or there are doubts about some question - you can ask a question in this way and get an answer first hand.
GO TO FULL VERSION