E-Dobavki is a web service for finding food supplements in Java and Spring Boot, written by my students

Introduction

It so happened that for the last almost two years I have been teaching programming in one of the IT schools in Kyiv. I took up this Just For Fun. Once I ran a blog on programming, then I abandoned it. But the desire to tell useful things to interested people has not gone away.

My main language is Java. I wrote mobile games, radio software, and various web services on it. And I teach Java.

Here I want to tell the story of the training of my last group. How they went from learning to writing a working web service. A useful web service for finding food supplements. Free, without ads, registration and SMS.

The service itself is E-Dobavki.com.

E-Dobavki is a web service for finding food supplements in Java and Spring Boot, written by my students

The project is educational, does not contain any advertising. As I understood from this publication, you can give links to such projects.

Before describing the project itself, I will tell you a little about the process of training the group, without this the picture will be incomplete.

9 months of training

At the school where I teach, the Java course is divided into 2 parts. In total, the course takes about 9 months, with all the breaks (New Year holidays, time to write intermediate projects).

The first part introduces students to the basic concepts of PL. Variables, methods, basic OOP and all that stuff.

The second part of the course provides that the student already more or less understands how to write in Java, and he can be given an "adult" technology stack. It all starts with SQL, then JDBC, Hibernate. Then HTTP, servlets. Further Spring, a little about git and maven. And students write final projects.

All training is divided into modules. I took classes twice a week. The duration of one lesson is two hours.

My approach to learning

I released 5 bands. It seems like a lot for two years, but I almost always led 2 groups in parallel.

I have tried different approaches.

The first option - this is one pair allocated for a presentation with a theory. The second pair is pure practice. This approach somehow worked, but the efficiency was not very, as for me.

The second option, which I came up with and which I am working on now, is not to allocate a whole pair for theory. Instead, I mix short pieces of theory for 5-10 minutes, and immediately reinforce them with practical examples. This approach works better.

If there is enough time, I call students to my place, seat me at my laptop, and they themselves make practical examples. This works great, but unfortunately it takes a lot of time.

Not everyone makes it to the end

The discovery for me was the fact that not the whole group reaches the end of the course.

According to my observations, only half of the students write the final draft. Most are eliminated in the first part of the course. And those who have reached the second part usually do not fall off.

They leave for various reasons.

The first is complexity. No matter what they say, Java is not the easiest language. To write even the simplest program, you need to understand the concept of a class, a method. And to understand why you need to write public static void main(String[] arg) there are a few more concepts to understand.

Compare this to Turbo Pascal, which many people, including myself, started with:

begin
    writeln("ΠŸΠ΅Ρ€Π²Π°Ρ ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ°");
end.

To solve this problem, as far as I know, the school will introduce additional testing. Now not everyone can go to learn Java. While it is at the concept stage, but the step is clearly the right one.

And the second reason is like in the picture below:

E-Dobavki is a web service for finding food supplements in Java and Spring Boot, written by my students

People often think that programming is when they type a lot of text and get a lot of money for it. Like a copywriter, only more money.

The reality is a little different. A lot of routine code, non-obvious bugs, a constant learning process. It's interesting, but not for everyone.

Such statistics. At first, it upset me, I thought that maybe I was doing something wrong. Now I understand that the statistics are about the same for most courses. Now I don’t worry about it, but I teach those people who are interested in it.

Service idea

When the students completed the full course, it was time to write the final project. There were different ideas. They offered ToDo lists, project management projects, something else.

I wanted to do something simple but useful. My criterion was simple - would my friends and I be able to use it. A web service for searching for nutritional supplements fit these requirements.

The idea is simple. When you buy a product in a store, you see some kind of E-supplement in the composition. It is not clear from the code how dangerous it is or not (and there are dangerous additives that are banned in many countries).

You open the site, type in the name of the additive (number, one of the alternative names), and get a summary of the additive:

E-Dobavki is a web service for finding food supplements in Java and Spring Boot, written by my students

There are similar projects. You can also just drive the add-on into Google, although it does not always show the information correctly.

But since the project is educational, the difficulties above did not stop us πŸ™‚

implementation

Everyone wrote in Java, project source code on github.

There were 7 of us including me. Everyone made a pull request, and I, or another person from the group, accepted this pull request.

The implementation of the project took about a month - from the voice of the idea to the state that you see now.

Addendum parsing

The first thing one of the students did, apart from the basic creation of a binding around the database (entities, repositories, etc.), was parsing add-ons from an existing information site.

This was necessary to test the rest of the points. No additional code is needed to populate the database. Having quickly parsed several additives, it was possible to further test the UI, sorting, filtering.

Spring Boot allows you to create multiple profiles. A profile is a file with settings.

For the dev environment, we used a profile with a local H2 DBMS and the default HTTP port (8080). Thus, each time the application was launched, the database was cleared. The parser in this case was the thing that saved us.

Search and filter

An important point is the search and filtering. The person in the store must quickly click on the supplement code, or some of the names, and get the result.

Therefore, the Additive entity has several fields. This is the additive code, alternative names, description. The search goes by Like in all fields at the same time. And if you enter [123] or [amaranth], you will get the same result.

We did all this on the basis of specifications (Specification). This is a part of Spring that allows you to describe the basic search conditions (like for some field, for example), and then combine these conditions (OR or AND).

After writing a dozen specifications, you can ask complex queries like "all dangerous dye additives that have the word [red] in the description."

In terms of working with the Spring database, it seems to me very convenient. This is especially evident when working with complex queries. I understand that this gives its overhead, and a manually written and optimized SQL query will run faster.

But I also adhere to the point of view that it is not necessary to optimize everything in advance. The first version should start, work, and allow the possibility of replacing individual parts. And if the load goes, these separate parts need to be rewritten.

Security

Everything is simple. There are users with the ADMIN role - they can edit additions, delete, add new ones.

And there are other users (registered or not). They can only look through the list of supplements and search for the ones they need.

Spring Security is used to separate permissions. User data is stored in the database.

Users can register. Now it does nothing. If students continue to develop the service and introduce some personalized features, then registration will come in handy.

Responsiveness and Bootstrap

The next point is adaptability. In the case of our service (at least in the way we've seen it), the majority of users will be on mobile phones. And from a mobile phone you need to quickly see the supplement.

In order not to suffer with CSS, we took Bootstrap. Cheap, cheerful, and looks decent.

I can not call the interface ideal. The main page is even less, and the page with a detailed description of the additive is narrow, on mobile phones you need to make it wider.

I can only say that I tried to interfere with the work to a minimum. It's still a student project. And of course, the guys will be able to fix such moments later.

A minute of SEO optimization

Since I have been closely involved in websites and everything related to SEO for more than two years now, I could not release a project without at least basic SEO optimization.

In fact, I made a template generation of Title and Description for each addon. The URL is almost NC, although it can be made shorter.

I also added attendance counters. Added a site to Yandex Webmaster and Google Search Console to track warnings from search engines.

It is not enough. You also need to add robots.txt and sitemap.xml for full indexing. But again, this is a student project. I will tell them what needs to be done, and if they want, they will do it.

You need to attach an SSL certificate. The free Let's Encrypt will also work. I did this for Spring Boot. It is easy to do, and the trust of the PS increases.

What's next for the project

After all, the choice is up to the guys. The original idea of ​​the project also included a database of products with links to additives.

Enter "snickers" and see what nutritional supplements it contains.

Even at the start of the project, I knew that we would not have products πŸ™‚ Therefore, we started only with additives.

Now you can fasten products, introduce additional. buns. If it is an extensive database, there will be users.

Deployment

The project was deployed on VPS, Aruba Cloud. This is the cheapest VPS we could find. I've been using this provider for over a year now for my projects and it makes me happy.

VPS specifications: 1 GB RAM, 1 CPU (I don't know for the frequency), 20 GB SSD. This is more than enough for our project.

The project is built with the usual mvn clean package. It turns out fat jar - an executable file with all dependencies.

To automate all this a little, I wrote a couple of bash scripts.

The first script removes the old jar file and builds the new one.

The second script runs the assembled jar, passing it the name of the profile you need. This profile contains database connection details.

DB - MySQL on the same VPS.

Total restart of the project includes:

  • login to VPS via SSH
  • download latest git changes
  • run local-jar.sh
  • kill running application
  • run launch-production.sh

This procedure takes three minutes. It seems like a reasonable choice to me for such a small project.

Difficulties

The main difficulties in creating the project were of an organizational nature.

There is a group of people who seem to be able to program, but not very much. They know something, but they still can’t really apply it. And now they need to complete the project in a month.

I singled out a conditional team leader in this group. He maintained a Google doc with a list of tasks, handed out tasks, controlled their acceptance. He also accepted pull requests.

I also asked the students to write a short report every evening on the work done on the project. Didn't do anything - ok, so write "didn't do anything." This is a great practice that makes you feel a little tense. Not everyone followed this rule, unfortunately.

The purpose of this whole movement was simple. Form a team, albeit for a short time, will work together.

I wanted the guys to have a sense of the importance of their work. Understand that they do not write spherical code in a vacuum. And what they are doing together is a project that people will then use.

The first week or two was a buildup. Entities, small commits were made sluggishly. Little by little, I stirred them up, and the work went more cheerfully. Chat communication became livelier, students offered their additions.

I believe that the goal has been achieved. The project is done, the guys got some experience of working in a team. There is a visible tangible result that can be shown to friends, can be further developed.

Conclusions

Learning is interesting.

After each pair, I came emotionally agitated. I try to make each pair unique and convey as much knowledge as possible.

It's nice when the group I teach reaches the final. It’s especially cool when the guys write β€œI got a job, everything is fine, thanks.” Let it be a junior, even if not the biggest money at first. But most importantly, they took a step towards their desires, and they succeeded.

The article, although it turned out to be quite voluminous, but of course it was not possible to reveal all the points. So write your questions in the comments.

Source: habr.com

Add a comment