Structuring the project

The application that will be developed in this chapter and the following two chapters must be more structured than a simple script with the whole code in it. So, this project will be structured as a Python package, which can be installed with the setup tools. Moreover, since it relies on more dependencies besides the small code examples used in the previous chapters, using the Python setup tools helps us deal with dependencies. But before looking at the structure of the project, let's start by looking into the functional specifications of this application.

The application is a daemon that allows us to transcode audio files from MP3 to the FLAC format. FLAC is a lossless audio codec. The transcoded files are stored in a specified directory. The daemon exposes an HTTP API that allows a client to upload an audio file so that it is transcoded and stored. The application must be configurable via a JSON configuration file. The following settings must be present in it:

  • The listening host address and port of the HTTP server
  • The location to store transcoded files

The following is a configuration file example:

{
"encode": {
"storage_path": "/tmp"
},
"server": {
"http": {
"host": "0.0.0.0",
"port": 8080
}
}
}

The reactivity of this application is shown in the following figure:

Figure 6.1: The audio encoder server reactivity diagram

There are three main parts in this project:

  • Parsing the configuration file
  • Encoding the audio files
  • Exposing the audio encoding service

Each of these parts relies on one or several drivers. The size of the drivers is kept as small as possible so that, as far as possible, the code consists of pure functions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.202.209