Before going on with modifications of the Docker compose file and the addition of the Mongo and Mongo
Express services there.
Let me explain to you why we actually require a database in our image gallery project because now it
consists only of two services front end and API without any database.
The moment front end is written in React talks to Flask API service that is written in Python and this
API service requests photos from the Unsplash API using Unsplash authorization key.
Now images are stored in the front end only temporarily, and each time when application in the front
end is reloaded, we start from empty list of images.
There are no images at that moment of time and we want to store actual images, actually information
about those images in the database in such way that after reload of the front end application, some
images that are already present in the database will be retrieved from it via Flask API service to the
front end.
It means that first we want to be able to store images in the MongoDB database and also we want to read
existing records from the MongoDB database.
And all of that will happen through Flask API service.
Not directly.
Front end will not talk directly to the MongoDB database.
Why?
I've chosen MongoDB database for this task.
It is NoSQL database and it is very very easy to use document schema is flexible.
This database is fast and also there are several very nice clients for Python and using such clients,
it is possible to perform all sorts of Crud operations on MongoDB database, but unfortunately MongoDB
database itself doesn't have any graphical user interface.
It has only CLI tool.
And for instance, if you want to test something and insert records directly inside of the MongoDB database
without any external client you could use for that mongo CLI utility.
Also, if you want to read existing records from the MongoDB database, you could use the same Mongo
utility as well, but it's not really convenient to use a command line utility and that's why we will
add another graphical user interface application and with help of such application we will be able to
perform different Crud operations directly on the MongoDB database using GUI web browser application
instead of command line utility.
That's why we will add two additional services to our Docker compose configuration, namely Mongo and
Mongo Express.
Luckily there are already corresponding images available at Docker Hub and we don't require to build
our own services like we did for API and front end service.
That's why addition of those two new services will be pretty straightforward.
Also, please notice that we want to keep data that we will write to the MongoDB database even when
we bring down all containers and afterwards bring them up again.
We want to restore data that was previously stored in the MongoDB database and we will be able to achieve
that with help of volumes.
Please note that integration of the database into the Image Gallery project is out of the scope of this
Docker course and we will stop here after creation of the infrastructure for further development.
But if you want to learn how to build such application with database, with all Crud operations, I
welcome you again to my full Stack Web Development Bootcamp.
All right, that's a review of what we will do next.
And let's get started with addition of Mongo and Mongo Express services into the Docker compose file
after the small pause.