<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by andrea mucci on Medium]]></title>
        <description><![CDATA[Stories by andrea mucci on Medium]]></description>
        <link>https://medium.com/@cingusoft?source=rss-d6b93e35c225------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qGA8g-EWtTj1NxJExc0Crg@2x.jpeg</url>
            <title>Stories by andrea mucci on Medium</title>
            <link>https://medium.com/@cingusoft?source=rss-d6b93e35c225------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 17:32:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cingusoft/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Microservices E-commerce Boutique Tutorial — Part 4]]></title>
            <link>https://blog.minos.run/microservices-e-commerce-boutique-tutorial-part-4-a49fbd286cf4?source=rss-d6b93e35c225------2</link>
            <guid isPermaLink="false">https://medium.com/p/a49fbd286cf4</guid>
            <category><![CDATA[domain-driven-design]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[event-sourcing]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[andrea mucci]]></dc:creator>
            <pubDate>Sun, 13 Mar 2022 13:55:44 GMT</pubDate>
            <atom:updated>2022-03-13T13:55:44.225Z</atom:updated>
            <content:encoded><![CDATA[<h3>Microservices E-commerce Boutique Tutorial — Part 4</h3><blockquote>You can find the code on our <a href="https://github.com/minos-framework/minos-python/tree/0.6.0/tutorials/eboutique">github repository</a></blockquote><p>In the previous posts we have seen in detail all the configurations of a microservice in <a href="https://github.com/minos-framework/minos-python">Minos</a> and how to do a test. In the next parts we will go faster and we will focus only on the new features.</p><p>Let’s create the Cart microservice</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bde73d820e99dc01b454950cec9f5113/href">https://medium.com/media/bde73d820e99dc01b454950cec9f5113/href</a></iframe><p>the CLI questions are always the same, just remember to put <strong>docker-compose</strong> as a deployment method.</p><p>The cart has the following Entities:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e4bb9af6f046bc289ddce09de7084956/href">https://medium.com/media/e4bb9af6f046bc289ddce09de7084956/href</a></iframe><p>The Cart is mainly composed of a <strong>RootEntity</strong> called <em>Cart</em> which refers to a <em>set</em> of <strong>Entities</strong> called <em>CartItem</em>.</p><p>However, what leaps to the eye is that <em>CartItem</em> has a reference to <em>Product</em>. <em>Product</em>, being an Entity of another microservice, inside Cart, will be represented by an ExternalEntity. Actually, an <strong>ExternalEntity</strong>, in a relational database for example, would be a reference to an <em>id</em> of another data. Since <em>Product</em> is a data managed by another microservice, the main reference will be with the uuid of <em>Product</em>.</p><p>The <strong>Aggregate</strong> class would be:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/61425d8156a775113289a567d38e2d4b/href">https://medium.com/media/61425d8156a775113289a567d38e2d4b/href</a></iframe><p>The Aggregate class uses the ORM functionalities to add, mainly the Cart and the CartItems.</p><p>Let’s have a look at the Command Service</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f6e00afa106507bceb789cd81f6aaeba/href">https://medium.com/media/f6e00afa106507bceb789cd81f6aaeba/href</a></iframe><p>In the <em>Command Service</em> we have two commands, mainly.</p><p>One is the command that is executed with a <em>POST</em> from the <em>REST</em> interface of the microservice to add a new Cart, <em>@enroute.rest.command(“/cart”, “POST”), </em>which simply gets the <strong>Request</strong> and, through the <strong>Aggregate</strong>, adds a new <em>Cart.</em></p><p>The substantial difference appears in the command to add a new item to the cart. The process of adding an <em>Item</em> to the cart consists in sending a <em>product_id</em>, a <em>quantity</em> and a <em>cart_id</em>. The <em>Command</em> process must check that the <em>product</em> being added exists, therefore it is necessary to interact with the <em>Product</em> microservice and at this point the SAGA comes into play.</p><p>A SAGA is a sequence of local transactions. Each local transaction updates the database and publishes a message or event to trigger the next local transaction in the saga. If a local transaction fails because it violates a business rule then the saga executes a series of compensating transactions that undo the changes that were made by the preceding local transactions. You can learn more about the theme of the SAGA in this <a href="https://microservices.io/patterns/data/saga.html">link</a>.</p><p>In Minos we have implemented a <em>Choreographic SAGA</em>, the process would be the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/465/1*tzYICBIryTYJQspu80IMsA.png" /></figure><p>The Cart item SAGA is extremely simple, but it helps to understand how, in a <strong>Minos microservice</strong>, it is possible to communicate with other microservices and therefore create even complex business logic processes.</p><p>To do that we have to create, in the command module, another module called saga and add the add_saga.py file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*txH_LBIVxY6mpm7HA3Uegg.png" /></figure><p>with the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/301b71f0fadec9ab76b80061dfbdd00c/href">https://medium.com/media/301b71f0fadec9ab76b80061dfbdd00c/href</a></iframe><p>The variable <em>ADD_CART_ITEM</em>, calls the <em>Saga</em> class which in turn launches a sequence of methods:</p><ul><li><strong>remote_step(callback)</strong>: used to instruct the saga that an Event must be launched towards an external microservice, this method takes as a parameter a callback method <em>_get_product, </em>the latter returns a <strong>SagaRequest</strong> which contains the name of the command that the Product must execute and a <em>DTO</em> <strong>ProductGet</strong> which contains the <em>id</em> of the product in question.</li><li><strong>on_error(callback)</strong>: used when the command returns an error like a 404.</li><li><strong>on_success(callback)</strong>: used when the remote_step returns a 200 response.</li><li><strong>commit(callback)</strong>: if everything goes well, the Saga Process sends a commit. In Minos, we have implemented a “2-Phase” commit. The Saga Manager sends a “Reserve” command and, if all the microservices involved in the SAGA transaction process return 200, sends the “Commit” command for all the microservices to update their own database state. In future articles we will describe in more detail the <em>commit process</em> of a SAGA, now it is only necessary to know that, during the execution period of a SAGA, the state of the microservices involved will not be updated, in this way we ensure the data consistency. The rest of the code is very similar to that of Product.</li></ul><p>The <strong>Query Service</strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a61b19a801ba472ed06bf1891126d0cf/href">https://medium.com/media/a61b19a801ba472ed06bf1891126d0cf/href</a></iframe><p>An interesting and unique feature in Minos is the resolve () command in line 49.<br>When the <em>query service</em> receives the<em> CartUpdated</em> event, it has a series of <em>items</em> that correspond to the products that need to be added to the <em>cart</em>. The product, however, is a Domain Model managed by another microservice, the <em>product</em> microservice, so the <em>Cart</em> microservice has no information related to this item, the resolve () method magically sends a command to the Product microservice and returns, for the <em>product</em> in question, the complete information such as, for example, the title, description, picture etc.</p><p>The <strong>Query Service Repository Models</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a40b36f493b9668abbbca16684a07e3/href">https://medium.com/media/4a40b36f493b9668abbbca16684a07e3/href</a></iframe><p>And the <strong>Query Service Repository</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a476f50378f572201e3419cd109f410c/href">https://medium.com/media/a476f50378f572201e3419cd109f410c/href</a></iframe><p>For these microservices we will use <strong>pytest</strong>.</p><p>First of all, you need to edit the file <em>external/postgres/init/10.create-database.sql</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/745f87ce3ba6e3688a9f113552072148/href">https://medium.com/media/745f87ce3ba6e3688a9f113552072148/href</a></iframe><p>this file is used during the <strong>docker compose</strong> <em>up</em> command and create the databases for all the microservices. Every time we add a new microservice we have to update that file. The DROP command is necessary only during the test process phase.</p><p>Now we have to add the tests for the cart microservice, we will add the <em>test_cart_microservice.py</em> in the <em>cart/tests</em> folder.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/02b0f85b6658e3eb188df930a2fa6a82/href">https://medium.com/media/02b0f85b6658e3eb188df930a2fa6a82/href</a></iframe><p>We have added two tests, one that adds a cart and one that adds an item.<br>This is enough just to run the pytest command.</p><blockquote>If you found this article interesting, then remember to leave a “clap” and a <strong>star</strong> in the <a href="https://github.com/minos-framework/minos-python">Minos repository</a></blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fopen.spotify.com%2Fembed%2Ftrack%2F5K3Q1gue9nWLLwh6bYQFoB%3Futm_source%3Doembed&amp;display_name=Spotify&amp;url=https%3A%2F%2Fopen.spotify.com%2Ftrack%2F5K3Q1gue9nWLLwh6bYQFoB&amp;image=https%3A%2F%2Fi.scdn.co%2Fimage%2Fab67616d00001e02cfccabf39d00d34235d5bcd6&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=spotify" width="456" height="80" frameborder="0" scrolling="no"><a href="https://medium.com/media/ee0e60ac3579eae10e95923cf0ace03b/href">https://medium.com/media/ee0e60ac3579eae10e95923cf0ace03b/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a49fbd286cf4" width="1" height="1" alt=""><hr><p><a href="https://blog.minos.run/microservices-e-commerce-boutique-tutorial-part-4-a49fbd286cf4">Microservices E-commerce Boutique Tutorial — Part 4</a> was originally published in <a href="https://blog.minos.run/">MinOS Framework</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Microservices E-commerce Boutique Tutorial — part 3]]></title>
            <link>https://blog.minos.run/microservices-e-commerce-boutique-tutorial-part-3-4b1cd8fb89ab?source=rss-d6b93e35c225------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b1cd8fb89ab</guid>
            <category><![CDATA[event-sourcing]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[domain-driven-design]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[andrea mucci]]></dc:creator>
            <pubDate>Fri, 11 Feb 2022 09:48:13 GMT</pubDate>
            <atom:updated>2022-03-05T14:49:55.515Z</atom:updated>
            <content:encoded><![CDATA[<h3>Microservices E-commerce Boutique Tutorial — Part 3</h3><blockquote>You can find the code on our <a href="https://github.com/minos-framework/minos-python/tree/0.6.0/tutorials/eboutique">github repository</a></blockquote><p>In the <a href="https://blog.minos.run/microservices-online-boutique-tutorial-part-2-9abd81ba771c">previous article</a> we have completed the creation of a microservice. Now we just have to test our product microservice.</p><p>To do that we need to install Tavern</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fc75d340facafdff9ab998b6ac5c73e0/href">https://medium.com/media/fc75d340facafdff9ab998b6ac5c73e0/href</a></iframe><p><strong>Tavern</strong> is a library that allows us to perform a quick test of our API and Minos microservices. In this article we will not explain how it works, however it is very simple.</p><p>First of all we need to enter in the <em>product/tests</em> folder and create a file called <em>test_product.tavern.yaml </em>and add the following content</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/73479a45bfd85bd290d8272a002f25df/href">https://medium.com/media/73479a45bfd85bd290d8272a002f25df/href</a></iframe><p>Basically, we create two stages (operations) that will call the POST command of Product and send two different types of products, after which we will check that the status response is 200. For the moment we check only the answer status code, but keep in mind that with Tavern it is possible to carry out much more elaborate tests.</p><p>Now we need to prepare our <em>docker-compose</em>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d554410637c9821a37cd0d294d9c1a96/href">https://medium.com/media/d554410637c9821a37cd0d294d9c1a96/href</a></iframe><p>and start the docker-compose</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d522dda23c40e9ac92f2f8c04277da76/href">https://medium.com/media/d522dda23c40e9ac92f2f8c04277da76/href</a></iframe><p>it is possible to add the <em>-d</em> parameter to the command, this allows you to <em>detach</em> the execution of the compose, however, we can see the logs of the various services.</p><p>Surely you will have noticed that some errors appear in the connection of the microservice to the database, this happens because the databases of our microservice have not been created yet, to do so, use the following command</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3bd4846f2b044edef870b67bb1e2586/href">https://medium.com/media/d3bd4846f2b044edef870b67bb1e2586/href</a></iframe><p>and create the database for <em>Query Service</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f01ae9675bfea932b99744d17a6caa8/href">https://medium.com/media/2f01ae9675bfea932b99744d17a6caa8/href</a></iframe><p>since in the docker-compose file we have configured the <em>product</em> service with <em>restart: always</em>, at the next restart the microservice will be operational.</p><p>Now we cant test everything with Tavern.</p><p>To launch Tavern, from the tests folder, use this command.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/73dc0b0a5593b2b413b239c60a626e7f/href">https://medium.com/media/73dc0b0a5593b2b413b239c60a626e7f/href</a></iframe><p>If everything went well you will get a result indicating that all tests have been successful.</p><p>As you can see, Tavern uses <em>pytest</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/08efe531a47e7ad9b097167378d1b8e7/href">https://medium.com/media/08efe531a47e7ad9b097167378d1b8e7/href</a></iframe><p>Congratulation, you have added your first products, now you can modify your Tavern file and add more products with different options.</p><p>Of course it is also possible to use pytest with a classic test code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bd086a6b54b95a87533af1c7f4af4ce5/href">https://medium.com/media/bd086a6b54b95a87533af1c7f4af4ce5/href</a></iframe><p>For this example it is better to install requests</p><blockquote><em>If you found this article interesting, then remember to leave a “clap” and a </em><strong><em>star</em></strong><em> in the </em><a href="https://github.com/minos-framework/minos-python"><em>Minos repository</em></a></blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fopen.spotify.com%2Fembed%2Ftrack%2F4iya38ctQ1httyA6NOG9oW%3Futm_source%3Doembed&amp;display_name=Spotify&amp;url=https%3A%2F%2Fopen.spotify.com%2Ftrack%2F4iya38ctQ1httyA6NOG9oW&amp;image=https%3A%2F%2Fi.scdn.co%2Fimage%2Fab67616d00001e02339cc033bcc476d11dffba4c&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=spotify" width="456" height="80" frameborder="0" scrolling="no"><a href="https://medium.com/media/49627310bfffc4aeb82dfb5f152938a5/href">https://medium.com/media/49627310bfffc4aeb82dfb5f152938a5/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b1cd8fb89ab" width="1" height="1" alt=""><hr><p><a href="https://blog.minos.run/microservices-e-commerce-boutique-tutorial-part-3-4b1cd8fb89ab">Microservices E-commerce Boutique Tutorial — part 3</a> was originally published in <a href="https://blog.minos.run/">MinOS Framework</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Microservices Online Boutique Tutorial — Part 2]]></title>
            <link>https://blog.minos.run/microservices-online-boutique-tutorial-part-2-9abd81ba771c?source=rss-d6b93e35c225------2</link>
            <guid isPermaLink="false">https://medium.com/p/9abd81ba771c</guid>
            <category><![CDATA[domain-driven-design]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[event-sourcing]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[andrea mucci]]></dc:creator>
            <pubDate>Sun, 06 Feb 2022 12:14:50 GMT</pubDate>
            <atom:updated>2022-03-05T14:49:31.408Z</atom:updated>
            <content:encoded><![CDATA[<h3>Microservices E-commerce Boutique Tutorial— Part 2</h3><blockquote>We have updated the post with some major changes. Due to a request from some users, it seemed appropriate to us to modify to docker-compose deployment process. 02/09/2022</blockquote><blockquote>You can find the code on our <a href="https://github.com/minos-framework/minos-python/tree/0.6.0/tutorials/eboutique">github repository</a></blockquote><p>In this second part of the tutorial we will create the first microservice of our project. Being the first contact with a Minos microservice, we will delve into the structure of the project and its main features.</p><h3>Create de Product Microservice</h3><p>from the project folder we have to call the following <a href="https://github.com/minos-framework/minos-cli">Minos CLI</a> commands:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e41f266263319c3f4c9caff48833da2/href">https://medium.com/media/9e41f266263319c3f4c9caff48833da2/href</a></iframe><p>The cli will ask us some questions:</p><ul><li>The name of the microservice ( <em>product</em> )</li><li>What kind of language do we want to use ( <em>python</em> ): for the moment Minos only supports Python, but the future has some great surprises in store ;-)</li><li>The microservice version ( <em>0.1.0 </em>)</li><li>The name of the RootEntity (<em>product</em> ). For the moment leave the configuration by default, later we will explain what a RootEntity is and what it is for.</li><li>The package manager ( <em>poetry</em> ). For the moment we support only Poetry as package manager.</li><li>The deploy that we want to use ( <em>docker-compose</em> ). In our previous post we set Kubernetes as our deployment service, so we maintain the same deployment for the microservices.</li><li>A series of questions about the general information of the project, such as the description, the name of the developer, etc.</li></ul><h3>The Microservice Folder structure</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*glJxeMn_0Koya_NbuKI9cQ.png" /></figure><ul><li>The <strong>src</strong> contain all the python project files.</li><li>The <strong>tests</strong> all the unit tests files.</li><li>In the <strong>root</strong> folder we have all the configuration files and the Poetry files.</li><li>In the root folder we have the Dockefile as well.</li></ul><p>Let’s take a look at the <em>config.yml</em> file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0501bba2ea8fb60a38d71038c92dae42/href">https://medium.com/media/0501bba2ea8fb60a38d71038c92dae42/href</a></iframe><p>This file contains all the configurations of the microservice.</p><p>From here you can:</p><ul><li>Modify the configurations of the database</li><li>Select the broker or the section injections</li><li>Use the plugins provided by Minos</li><li>Usa a custom plugin, for example RabbitMQ.</li></ul><p>In this tutorial we will not go into detail on how to reconfigure the microservice, we will use the default data.</p><p>Well, now let’s get into the code in python (finally !!!).</p><p>The src folder contains:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/1*wRIAtJoxJM8kcjcFMnuXMA.png" /></figure><ul><li>the <strong>commands</strong> module.</li><li>the <strong>queries</strong> module.</li><li>the <strong>aggregates</strong> file.</li></ul><p>Let’s see what each of them does.</p><h3>Aggregates</h3><blockquote>An Aggregate defines a self-contained grouping of entities, which is treated as a single, atomic unit. A change to any of the entities is considered to be a change to the entire Aggregate.</blockquote><p>Ok, let’s try to clarify the concept a little better. In our microservice we know that we will deal with the product catalog, so our main <strong>Entity</strong> or <strong>RootEntity</strong> is Product.</p><p>A product will have the following attributes:</p><ul><li>id: <em>uuid string</em></li><li>name: <em>string</em></li><li>description: <em>text</em></li><li>picture: <em>string</em></li><li>price <em>Entity</em><br>- id: <em>string</em><br>- currencyCode: <em>string</em><br>- units: <em>int</em></li><li>categories: <em>list</em></li></ul><p>Notice that Price is an Entity, and Categories is a list or Value Object, we will delve into that in a moment.</p><p>Before, see how we reflect this model in the aggregates.py:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/076821b396a091df225715eb753adfdd/href">https://medium.com/media/076821b396a091df225715eb753adfdd/href</a></iframe><p>From the code it is clear that</p><ul><li>An Entity is very similar to the concept of Model that we have encountered in other frameworks such as Django, for example.</li><li>The <em>name</em>, <em>description</em> and <em>picture</em> attributes use the native Python <em>typing</em> and are therefore strings (str).</li><li>The <em>price</em>, on the other hand, is a reference to an <em>Entity</em> class called <strong>Price. </strong>An Entity class is very similar to a RootEntity and the reference is very similar to the ForeignKey of a classic ORM, so <em>Product</em> has an <em>OneToOne</em> relationship with <em>Price.</em></li><li><em>Categories</em>, on the other hand, has a different concept, at first sight it would seem a “normal” OneToMany relationship (and it is), but this relationship does not take place through an id, instead the given list of categories is loaded entirely inside the object Product.</li></ul><p>Now we have our set of Entities ready, it is time to create a set of methods to manage them and this is where the aggregate comes into play.</p><p>We will create three basic CRUD methods: add, get and delete.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/257a32fdb026c1b532711b09f79230ef/href">https://medium.com/media/257a32fdb026c1b532711b09f79230ef/href</a></iframe><p>These operations will change the state of the <em>Event Storer.</em></p><p><strong>What can we do with the Aggregate class?</strong> The aggregate mainly works with the <em>Event Storer</em> and the <em>Snapshot</em> (in other articles we will describe better what are those two patterns and how Minos implement them), so the Aggregate class is extensively used in the <em>Command Service.</em></p><h3><em>Command Service</em></h3><blockquote>CQRS separates reads and writes into different models, using commands to update data, and queries to read data.</blockquote><p>In Minos, the Command Service is in charge of modifying the Event Storer and exposing the commands for that purpose.</p><p>In our Command Service we want to define three main commands:</p><ul><li>create_product</li><li>get_product_by_id</li><li>delete_product</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/176e1585fd644ee811c3c73403dcf933/href">https://medium.com/media/176e1585fd644ee811c3c73403dcf933/href</a></iframe><p>Let’s take some time to analyze the Command Service.</p><p>As you can see the methods have been <strong>decorated</strong> with two different functions:</p><p><strong>@enroute.rest.command(“…”, “POST”)</strong></p><p>The Command Service receive the enrouting from the REST interface for all the following HTTP commands:</p><ul><li>POST</li><li>PUT</li><li>DELETE</li></ul><p>then, the “@<em>enroute.rest.command()</em>” decorator, instructs the REST Interface to enroute all the calls to a specific method.</p><p><strong>@enroute.broker.command(….)</strong></p><p>This decorator, as its name implies, routes the broker’s calls, hence the events coming from the broker. Although it may seem confusing to talk about events within the Command Service, it is necessary to clarify that the Commands are Events with a different payload.</p><p>There remains only one method in our <em>Command Service</em> that has a different functionality than the others.</p><p><em>async def get_product_by_id(…)</em></p><p>So far we have said that the Command Service takes care of doing the Write operations on the Event Storer, so why put a retrieve method?</p><p>The answer is simple, because the Command Service has the duty to carry out the writes but, at the same time, it is the communication interface between the microservices themselves.</p><p>Whenever a microservice needs to add data or request data from another microservice, it has to go through the Command Service Interface. Moreover, the queries, passing through the Event Storer, will always maintain <em>data consistency.</em></p><h3>Query Service</h3><p>The query Service is the service that is responsible for returning the data. The <em>Query Service</em>, unlike the <em>Command Service</em>, does not read from the <em>Event Storer</em>, hindsight from a database that the programmer has chosen.<br>To do this we will use two features offered by Minos</p><ul><li>MinosSetup</li><li>Dependency injection</li></ul><p>The <em>Minos CLI</em> will provide a default configuration of the <em>Query Service</em> with SQLAlchemy and postgreSQL. The postgreSQL host would be the same used for the <em>Event Storer.</em></p><p><strong>Repository.py</strong></p><p>If you need to configure something during the startup process of the microservice, extend <em>MinosSetup </em>class<em> </em>would be the<em> s</em>olution.<br>Open the <em>repository.py</em> file</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9b4f08b790c4a7c22b4f13305f65f614/href">https://medium.com/media/9b4f08b790c4a7c22b4f13305f65f614/href</a></iframe><p>In the repository.py file you already have all the injections configured and the information coming from the MinosConfig instance.<br>In repository.py we will add the<em> add, get_all </em>and<em> get methods</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/727691aeef54552c139476aa8a5323d8/href">https://medium.com/media/727691aeef54552c139476aa8a5323d8/href</a></iframe><p>in the Add method we see that we use, as a parameter, an Event.</p><p>It’s worthwhile to dwell on the Event class a little bit.<br>The <em>QueryService</em> normally receives a Request, it is almost used as a REST — GET call handler. <br>However, there is a special case and it is when events, from the Aggregate, arrive and the Query Service use it to compose one or more data between them. <br>In a nutshell, when an Aggregate <em>adds</em>, <em>modifies</em> or <em>deletes</em> an <em>Entity</em>, it will send an event. This event is captured by the QueryService of one or more microservices and these in turn as something the the QueryService understand.</p><p>So, in the case of <em>add</em> method, this receive the <strong>Event</strong> <em>ProductCreated </em>and<em> </em>extract the attributes like <em>title</em>, <em>description</em> and <em>uuid.</em></p><p><strong>Models.py</strong></p><p>The models.py provide the declarative base class from sqlalchemy.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e62405a298f60743d829164f44b73620/href">https://medium.com/media/e62405a298f60743d829164f44b73620/href</a></iframe><p>From that point, we can add all the sqlalchemy models we need. For our product microservice we replicate the aggregate structure</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/99d7f50d39cdc4f08a6a475a07f10e3e/href">https://medium.com/media/99d7f50d39cdc4f08a6a475a07f10e3e/href</a></iframe><p><strong>Dependency injection</strong></p><p>Once the query service database has been configured, we can start configuring our Q<em>ueryService.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1cbef170c2d33f698e3c9f2caf3be18d/href">https://medium.com/media/1cbef170c2d33f698e3c9f2caf3be18d/href</a></iframe><p>In our QueryService, we integrate HTTP GET commands and the events coming from our microservice and, if needed, events from others microservices.<br>The treatment of the events in the QueryService is a very important milestone. The events are generated by the Aggregates during the CUD processes, so the QueryService can get all that information and from that point create the structure of the data.</p><p><em>In the 3 part of this tutorial we will deploy the product microservice and all the services required and we test it</em></p><blockquote>If you found this article interesting, then remember to leave a “clap” and a <strong>star</strong> in the <a href="https://github.com/minos-framework/minos-python">Minos repository</a></blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fopen.spotify.com%2Fembed%2Ftrack%2F2dxjKgT0li4qBI3QwuN9Ih%3Futm_source%3Doembed&amp;display_name=Spotify&amp;url=https%3A%2F%2Fopen.spotify.com%2Ftrack%2F2dxjKgT0li4qBI3QwuN9Ih&amp;image=https%3A%2F%2Fi.scdn.co%2Fimage%2Fab67616d00001e02428d2255141c2119409a31b2&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=spotify" width="456" height="80" frameborder="0" scrolling="no"><a href="https://medium.com/media/b2312275acc0721cd3084a6439aea3c1/href">https://medium.com/media/b2312275acc0721cd3084a6439aea3c1/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9abd81ba771c" width="1" height="1" alt=""><hr><p><a href="https://blog.minos.run/microservices-online-boutique-tutorial-part-2-9abd81ba771c">Microservices Online Boutique Tutorial — Part 2</a> was originally published in <a href="https://blog.minos.run/">MinOS Framework</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Microservices Online Boutique Tutorial — Part 1]]></title>
            <link>https://blog.minos.run/microservices-online-boutique-tutorial-part-1-ea9287d34c83?source=rss-d6b93e35c225------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea9287d34c83</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[domain-driven-design]]></category>
            <category><![CDATA[event-sourcing]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[andrea mucci]]></dc:creator>
            <pubDate>Sat, 05 Feb 2022 16:31:08 GMT</pubDate>
            <atom:updated>2022-03-05T14:50:20.938Z</atom:updated>
            <content:encoded><![CDATA[<h3>Microservices E-commerce Boutique Tutorial — Part 1</h3><blockquote><em>We have updated the post with some major changes. Due to a request from some users, it seemed appropriate to us to modify to docker-compose deployment process. 02/09/2022</em></blockquote><blockquote>You can find the code on our <a href="https://github.com/minos-framework/minos-python/tree/0.6.0/tutorials/eboutique">github repository</a></blockquote><p>Welcome to the <a href="https://github.com/minos-framework/minos-python">Minos Framework</a> tutorial.</p><p>The idea of ​​this tutorial is to create an Online E-commerce Boutique with Minos cloud-native microservices. The project consists of an application of 9-tier microservices. The final result will be an API REST that will allow you to perform the basic operations of an e-commerce.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*XiJ9b3azMNb68XOmYXbhmQ.png" /><figcaption>The complete structure of 9 microservices with the API-gateway and the discovery services</figcaption></figure><h3>What is Minos</h3><p>Minos is a framework that helps you create reactive microservices in Python. Internally, it leverages Event Sourcing, CQRS and a message-driven architecture to fulfill the commitments of an asynchronous environment.</p><h3>Requirements</h3><ul><li>python 3.9+</li><li><a href="https://python-poetry.org/">Poetry</a></li><li>Docker and docker-compose</li></ul><h3>Installation</h3><p>install the minos-cli</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f7d2a78e4eb1e4314a2211266c3c5d40/href">https://medium.com/media/f7d2a78e4eb1e4314a2211266c3c5d40/href</a></iframe><h3>Create the Project</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/18e2d1177afb18699c824842480c4ebe/href">https://medium.com/media/18e2d1177afb18699c824842480c4ebe/href</a></iframe><p>The cli will ask you:</p><ul><li>the <strong>name</strong> of the project ( <em>myboutique</em> )</li><li>the <strong>description</strong> of the project ( My fantastic online boutique )</li><li>The <strong>version</strong> ( 0.1.0 ), is not necessary to modify this information during the quickstart</li></ul><p>With this, the project structure is created, now we will configure the database and the broker message.</p><p>Go to the <em>myboutique</em> folder and let’s start by <strong>configuring the database</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/237561aac8f59612f5724568d76bb3a2/href">https://medium.com/media/237561aac8f59612f5724568d76bb3a2/href</a></iframe><p>The CLI will ask:</p><ul><li>where do we want to <strong>deploy</strong> our project? for this project we will use docker-compose</li><li>Where will be <strong>PostgreSQL</strong> database hosted? we have two options <em>self-hosted</em> and <em>remote. <br> - </em><strong>Self-Hosted: </strong>which<strong> </strong>mean that we install a POD in our kubernetes, which<br> is our case.<br> - <strong>Remote: </strong>this option would be if we already have a PostgreSQL instance in our laptop or in a remote server.<br>Select <strong>self-hosted</strong> option.</li></ul><p>Now we will continue by <strong>configuring the broker service</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/50876dfc08976fbadae56d0e5c8d47d1/href">https://medium.com/media/50876dfc08976fbadae56d0e5c8d47d1/href</a></iframe><p>the CLI will ask if we want to use a self-hosted or a remote Kafka broker, we <strong>choose self-hosted option</strong>.</p><h3>Deploy the project</h3><p>before we start creating the microservices, we have to test our project and deploy the project.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/45b525dc44193e20c6233e2b64c3b5ff/href">https://medium.com/media/45b525dc44193e20c6233e2b64c3b5ff/href</a></iframe><p>after some time, we will see the required services already up.</p><p>Now, finally, we can create the first Microservice.</p><p><a href="https://blog.minos.run/microservices-online-boutique-tutorial-part-2-9abd81ba771c">Tutorial part 2 — Product Catalog Microservice</a></p><blockquote>If you found this article interesting, then remember to leave a “clap” and a <strong>star</strong> in the <a href="https://github.com/minos-framework/minos-python">Minos repository</a></blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fopen.spotify.com%2Fembed%2Ftrack%2F71yCMlsD6qbD7NmNUEoVNR%3Futm_source%3Doembed&amp;display_name=Spotify&amp;url=https%3A%2F%2Fopen.spotify.com%2Ftrack%2F71yCMlsD6qbD7NmNUEoVNR&amp;image=https%3A%2F%2Fi.scdn.co%2Fimage%2Fab67616d00001e02168b00b7ccd04a5cf38cd74e&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=spotify" width="456" height="80" frameborder="0" scrolling="no"><a href="https://medium.com/media/762181d64c4ec9f741aaa90eedf5f9f6/href">https://medium.com/media/762181d64c4ec9f741aaa90eedf5f9f6/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea9287d34c83" width="1" height="1" alt=""><hr><p><a href="https://blog.minos.run/microservices-online-boutique-tutorial-part-1-ea9287d34c83">Microservices Online Boutique Tutorial — Part 1</a> was originally published in <a href="https://blog.minos.run/">MinOS Framework</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hand Sanitizer homemade]]></title>
            <link>https://medium.com/pixel-heart/hand-sanitizer-homemade-13d0054804a9?source=rss-d6b93e35c225------2</link>
            <guid isPermaLink="false">https://medium.com/p/13d0054804a9</guid>
            <category><![CDATA[oms]]></category>
            <category><![CDATA[hand-sanitizer-gel]]></category>
            <category><![CDATA[hand-sanitizer]]></category>
            <category><![CDATA[coronavirus]]></category>
            <dc:creator><![CDATA[andrea mucci]]></dc:creator>
            <pubDate>Sun, 08 Mar 2020 19:07:41 GMT</pubDate>
            <atom:updated>2020-03-08T19:10:23.123Z</atom:updated>
            <content:encoded><![CDATA[<p>OMS Recipe</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ArWlVP3n-CuLD_EOzQgkRg.jpeg" /></figure><p>The best way to reduce coronavirus infection is to increase personal hygiene, especially for the hands.<br>Using masks without being infected is, as well as useless, also a way to speed up the process of contagion, because you are brought to touch your face to adjust the mask when move.<br>So in case you have trouble finding a hand sanitizer, OMS has made public a recipe for making a hand sanitizer at home.</p><h4>What do you need:</h4><ol><li>Pure alcohol 96 (the simple alcohol for making alcoholic drinks)</li><li>Purified water</li><li>Hydrogen peroxide at 3% or 10 volumes</li><li>Glycerol (you can find it in the pharmacy or even on the internet)</li><li>1 liter graduated container</li></ol><h4>The procedure:</h4><ol><li>Pour 833ml of alcohol into the container (don’t worry if you’re not super precise)</li><li>Pour 42ml of hydrogen peroxide</li><li>Mix</li><li>Add 15 ml of glycerol, we need glycerol to make the solution more viscous and therefore similar to a gel.</li><li>Mix</li><li>Add purified water up to one liter (if you do not have purified water available you can use previously boiled normal water)</li><li>Mix and leave to rest for a few minutes</li></ol><p>The gel is ready.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13d0054804a9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/pixel-heart/hand-sanitizer-homemade-13d0054804a9">Hand Sanitizer homemade</a> was originally published in <a href="https://medium.com/pixel-heart">Pixel Heart</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Howto dump Geonames into PostgreSQL and postGIS]]></title>
            <link>https://medium.com/pixel-heart/howto-dump-geonames-into-postgresql-and-postgis-395fab58f4bc?source=rss-d6b93e35c225------2</link>
            <guid isPermaLink="false">https://medium.com/p/395fab58f4bc</guid>
            <category><![CDATA[postgis]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[postgresql]]></category>
            <dc:creator><![CDATA[andrea mucci]]></dc:creator>
            <pubDate>Wed, 16 Nov 2016 23:43:38 GMT</pubDate>
            <atom:updated>2016-11-16T23:43:38.423Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*EISKHXiue3PiA5OiIogY3w.png" /></figure><p>This is a very short article explaining howto dump Geonames files into PostgreSQL without any special script or slow code.</p><p>first you have to download the related geonames files and unzip it</p><pre>wget http://download.geonames.org/export/dump/allCountries.zip<br>wget http://download.geonames.org/export/dump/alternateNames.zip<br>wget http://download.geonames.org/export/dump/countryInfo.txt</pre><p>Now you have to create a database with the postgis templates active and after that we can create the related tables</p><pre>create table geoname (<br>    geonameid   int,<br>    name varchar(200),<br>    asciiname varchar(200),<br>    alternatenames text,<br>    latitude float,<br>    longitude float,<br>    fclass char(1),<br>    fcode varchar(10),<br>    country varchar(2),<br>    cc2 varchar(120),<br>    admin1 varchar(20),<br>    admin2 varchar(80),<br>    admin3 varchar(20),<br>    admin4 varchar(20),<br>    population bigint,<br>    elevation int,<br>    gtopo30 int,<br>    timezone varchar(40),<br>    moddate date<br> );</pre><pre>create table alternatename (<br>    alternatenameId int,<br>    geonameid int,<br>    isoLanguage varchar(7),<br>    alternateName varchar(200),<br>    isPreferredName boolean,<br>    isShortName boolean,<br>    isColloquial boolean,<br>    isHistoric boolean<br> );</pre><pre>create table &quot;countryinfo&quot; (<br>    iso_alpha2 char(2),<br>    iso_alpha3 char(3),<br>    iso_numeric integer,<br>    fips_code varchar(3),<br>    name varchar(200),<br>    capital varchar(200),<br>    areainsqkm double precision,<br>    population integer,<br>    continent varchar(2),<br>    tld varchar(10),<br>    currencycode varchar(3),<br>    currencyname varchar(20),<br>    phone varchar(20),<br>    postalcode varchar(100),<br>    postalcoderegex varchar(200),<br>    languages varchar(200),<br>    geonameId int,<br>    neighbors varchar(50),<br>    equivfipscode varchar(3)<br>);</pre><p>now you can use pgAdmin or the command shell, in all the cases you have to grant the permissions to the files to import, you can do this with this command</p><pre>chmod a+rX /Users/ogonbat /Users/ogonbat/Documents/ /Users/ogonbat/Documents/allCountries.txt</pre><p>in this example i have downloaded and unzipped the file into the Documents folder, so you have to grant access to all the folders that contain the files, repeat the action for all the downloaded files<br>After to that you can use the command shell or the pgAdmin Query tool to import the files.</p><pre>copy geoname (geonameid,name,asciiname,alternatenames,latitude,longitude,fclass,fcode,country,cc2,admin1,admin2,admin3,admin4,population,elevation,gtopo30,timezone,moddate) from &#39;/Users/ogonbat/Documents/allCountries.txt&#39; null as &#39;&#39;;</pre><pre>copy alternatename  (alternatenameid,geonameid,isolanguage,alternatename,ispreferredname,isshortname,iscolloquial,ishistoric) from &#39;/Users/ogonbat/Documents/alternateNames.txt&#39; null as &#39;&#39;;</pre><pre>copy countryinfo (iso_alpha2,iso_alpha3,iso_numeric,fips_code,name,capital,areainsqkm,population,continent,tld,currencycode,currencyname,phone,postalcode,postalcoderegex,languages,geonameid,neighbors,equivfipscode) from &#39;/Users/ogonbat/Documents/countryInfo.txt&#39; null as &#39;&#39;;</pre><p>Now is time to create the primary-keys and the foreign-keys</p><pre>ALTER TABLE ONLY alternatename<br>      ADD CONSTRAINT pk_alternatenameid PRIMARY KEY (alternatenameid);<br>ALTER TABLE ONLY geoname<br>      ADD CONSTRAINT pk_geonameid PRIMARY KEY (geonameid);<br>ALTER TABLE ONLY countryinfo<br>      ADD CONSTRAINT pk_iso_alpha2 PRIMARY KEY (iso_alpha2);<br><br>ALTER TABLE ONLY countryinfo<br>      ADD CONSTRAINT fk_geonameid FOREIGN KEY (geonameid) REFERENCES geoname(geonameid);<br>ALTER TABLE ONLY alternatename<br>      ADD CONSTRAINT fk_geonameid FOREIGN KEY (geonameid) REFERENCES geoname(geonameid);</pre><p>and finally you have to generate the Postgis points</p><pre>SELECT AddGeometryColumn (&#39;public&#39;,&#39;geoname&#39;,&#39;the_geom&#39;,4326,&#39;POINT&#39;,2);<br><br>UPDATE geoname SET the_geom = ST_PointFromText(&#39;POINT(&#39; || longitude || &#39; &#39; || latitude || &#39;)&#39;, 4326);<br><br>CREATE INDEX idx_geoname_the_geom ON public.geoname USING gist(the_geom);</pre><p>That’s all, this is a partial dump, have more informations that can be added from geonames, but the process is still the same for every file.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=395fab58f4bc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/pixel-heart/howto-dump-geonames-into-postgresql-and-postgis-395fab58f4bc">Howto dump Geonames into PostgreSQL and postGIS</a> was originally published in <a href="https://medium.com/pixel-heart">Pixel Heart</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OS X Sierra, PostgreSQL and Psycopg2]]></title>
            <link>https://medium.com/pixel-heart/os-x-sierra-postgresql-and-psycopg2-42c0c95acb23?source=rss-d6b93e35c225------2</link>
            <guid isPermaLink="false">https://medium.com/p/42c0c95acb23</guid>
            <category><![CDATA[psycopg2]]></category>
            <category><![CDATA[os-x]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[andrea mucci]]></dc:creator>
            <pubDate>Mon, 07 Nov 2016 19:11:16 GMT</pubDate>
            <atom:updated>2016-11-07T20:33:40.844Z</atom:updated>
            <content:encoded><![CDATA[<p>This is a classic post explaining how to install psycopg2 ( a python driver for pgsql ) and a virtualenv environment.<br>The first step is download the PostgreSQL server from the <a href="http://www.enterprisedb.com/products-services-training/pgdownload">official page</a>.<br>After the PgSQL installation it’s time to install the drivers for python.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*sSzO9HpsKbFCekkXCoxR2w.png" /></figure><p>First of all we need to include pg_config in our $PATH.<br>But where is pg_config?<br>easy, open your terminal and paste this code:</p><pre>find / -name pg_config 2&gt;/dev/null</pre><p>If you have installed the actual latest version of PgSQL, you should obtain something like that</p><pre>/Library/PostgreSQL/9.6/bin/pg_config</pre><p>Now we have to update how <em>.bash_profile</em> file and we have to add the folder containing the <em>pg_config</em> executable, like that</p><pre>export PATH=”/usr/local/bin:/Library/PostgreSQL/9.6/bin:$PATH”</pre><p>Close the terminal and reopen it, to check if all work well type in the terminal</p><pre>echo $PATH</pre><p>if you see the PgSQL folder, mean that all work well :-)<br>Now we have to activate our virtualenv environment and we can install psycopg2 package</p><pre>pip install psycopg2</pre><p>Now seems that all work well, but no, we have todo some tricks more<br>If you launch python from the terminal and type this</p><pre>import psycopgs</pre><p>the interpreter will return an error</p><pre>ImportError: dlopen(/Users/cingusoft/testenv/lib/python2.7/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: libssl.1.0.0.dylib</pre><p>to solve this problem you have todo some final step.<br>First of all you have to disable de <em>System Integrity Protection</em> in your mac, this because you have to create some symlink in <em>/usr/lib</em> and the SIP shall block this operation.<br>To disable the SIP you have to shutdown and restart with the keys CMD+R on hold, after the boot enter in the Utilities, open the terminal and type</p><pre>csrutil disable</pre><p>now reboot.<br>After that you have to create the symlinks</p><pre>sudo ln -s /Library/PostgreSQL/9.6/lib/libssl.1.0.0.dylib /usr/lib<br>sudo ln -s /Library/PostgreSQL/9.6/lib/libcrypto.1.0.0.dylib /usr/lib</pre><p>In my case i have installed PgSQL 9.6<br>In my case all work well now, but if you obtain more errors you can link <em>libpq</em> too</p><pre>sudo mv /usr/lib/libpq.5.dylib /usr/lib/libpq.5.dylib.old  <br>$ sudo ln -s /Library/PostgreSQL/9.6/lib/libpq.5.dylib /usr/lib</pre><p>that’s all, i hope have fun with my post</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42c0c95acb23" width="1" height="1" alt=""><hr><p><a href="https://medium.com/pixel-heart/os-x-sierra-postgresql-and-psycopg2-42c0c95acb23">OS X Sierra, PostgreSQL and Psycopg2</a> was originally published in <a href="https://medium.com/pixel-heart">Pixel Heart</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Parse.com Bye Bye and FucK You]]></title>
            <link>https://medium.com/pixel-heart/parse-com-bye-bye-and-f-k-you-4d719aaa082b?source=rss-d6b93e35c225------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d719aaa082b</guid>
            <category><![CDATA[parse]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[andrea mucci]]></dc:creator>
            <pubDate>Fri, 29 Jan 2016 08:49:14 GMT</pubDate>
            <atom:updated>2016-11-16T23:46:38.142Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*NuQwxR0qs7X-OZEgTPJg1Q.png" /></figure><p>The same old story and it repeats year after year.<br>A society that offers a good idea, is bought by a giant, it makes you migrate services and products and then, nice day tells you that closes down and leaves you with the butt out.<br>This time, fortunately, I did not have great things, but I know exactly what it feels like.<br><strong>How can you react to this shame?<br></strong>Internet has created a dynamic and young economy offering a thousand opportunities, but at the same time is missing the respect for the customer, the desire to maintain a product over time and grow with its customers.</p><blockquote>We’re proud that we’ve been able to help so many of you build great mobile apps, but we need to focus our resources elsewhere.</blockquote><p>What does this sentence mean?<br>According toParse what are “our resources”?<br>Just this week I wanted to develop a library to integrate Dart and Angular2 with Parse, I was excited because I was convinced that MBaaS solutions like Parse as were the future ….</p><p><strong>I was wrong!!!</strong></p><p><strong>The future is a dictatorship run by three or four mega corporations disguised as startups.</strong></p><p>The only one that remains is the meager satisfaction of shouting …..</p><h3><strong>PARSE FUCK YOU!!!!!</strong></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d719aaa082b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/pixel-heart/parse-com-bye-bye-and-f-k-you-4d719aaa082b">Parse.com Bye Bye and FucK You</a> was originally published in <a href="https://medium.com/pixel-heart">Pixel Heart</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Typescript+Gulp+Browserify+Less+Web Server LiveReload]]></title>
            <link>https://medium.com/pixel-heart/typescript-gulp-browserify-less-web-server-livereload-2ccdcbc6be1d?source=rss-d6b93e35c225------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ccdcbc6be1d</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[gulp]]></category>
            <dc:creator><![CDATA[andrea mucci]]></dc:creator>
            <pubDate>Fri, 23 Oct 2015 16:18:54 GMT</pubDate>
            <atom:updated>2017-02-27T23:16:52.192Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3CiMgJkSbc2drJMduoAzKA.jpeg" /></figure><p>In this tutorial we create an all-in-one gulp configuration file for Typescript.<br>First we have to create our project folder, for example “MyTypeScriptProj”.<br>First dependencies are:<br>NPM and Node<br>So you have to install it, the installation process is out of scope of this tutorial, but is very easy todo, simply go to <a href="https://nodejs.org/">node website</a> and download the installer.</p><p>Now go to the project folder and activate npm:</p><pre>npm init</pre><p>this create a pacgkage.js file ( you have to answer some questions before the file creation ).<br>Now is time to install some global packages:</p><pre>$:&gt; npm install typescript -g</pre><pre>$:&gt; npm install gulp -g</pre><pre>$:&gt; npm install tsd -g</pre><p><strong>You have to have the correct rights to install npm global packages.</strong></p><p>Now is time to install packages for our project</p><pre>$:&gt; npm install gulp  — save-dev</pre><pre>$:&gt; npm install gulp-connect  — save-dev</pre><pre>$:&gt; npm install gulp-less  — save-dev</pre><pre>$:&gt; npm install gulp-typescript — save-dev</pre><pre>$:&gt; npm install gulp-watch — save-dev</pre><pre>$:&gt; npm install browserify— save-dev</pre><pre>$:&gt; npm install tsd— save-dev</pre><pre>$:&gt; npm install typescript— save-dev</pre><pre>$:&gt; npm install vinyl-source-stream— save-dev</pre><p>As you can see we have replicated some global packages, like gulp or typescript, this is because sometime gulp return some errors during the compilation</p><p>Now we have all the packages installed, is time to create the <em>project folder structure, typescript configuration file tsconfig.json and gulp tasks</em>.</p><p>create a <strong>src</strong> folder,<br>create a <strong>src/styles</strong> folder<br>create a <strong>src/assets</strong> folder</p><p>Into <strong>src</strong> folder create a <strong>tsconfig.json</strong> file, this is a configuration file for typescript introduced in typescript 1.5 and give all the informations for the scripts compilation.</p><p><strong>src/tsconfig.json</strong>:</p><pre>{<br> “compilerOptions”: {<br>     “target”: “es5”,<br>     “module”: “commonjs”,<br>     “isolatedModules”: false,<br>     “jsx”: “react”,<br>     “experimentalDecorators”: true,<br>     “emitDecoratorMetadata”: true,<br>     “declaration”: false,<br>     “noImplicitAny”: true,<br>     “removeComments”: true,<br>     “noLib”: false,<br>     “preserveConstEnums”: true,<br>     “suppressImplicitAnyIndexErrors”: true<br> },<br> “compileOnSave”: false,<br> “files”: [<br>     “../typings/tsd.d.ts”,<br>     “main.ts”<br> ]<br>}</pre><p>The description of this file is quite boring, but you can find all the informations about the different options <a href="https://github.com/Microsoft/TypeScript/wiki/tsconfig.json">here</a>.<br>Is important to take in care the<strong> files</strong> options.<br>This option define which files we have to compile, pay attention to <strong>typings</strong> folder, this folder is automatic created by <strong>tsd</strong>.</p><p>Now, in the project root folder, we can create <strong>gulpfile.js</strong></p><p><strong>gulpfile.js</strong></p><pre>var gulp = require(‘gulp’);<br>var ts = require(‘gulp-typescript’);<br>var watch = require(‘gulp-watch’);<br>var browserify = require(‘browserify’);<br>var source = require(‘vinyl-source-stream’);<br>var less = require(‘gulp-less’);<br>var tsProject = ts.createProject(‘./src/tsconfig.json’);<br>var connect = require(‘gulp-connect’);</pre><pre>/*<br>compile typescript<br>use ES5 and commonJS module<br>*/<br>gulp.task(‘typescript’, function() {<br>    /* <br>     old version<br>     var tsResult = tsProject.src().pipe(ts(tsProject));<br>     changed for<br>    */<br>    tsResult = tsProject.src().pipe(tsProject());</pre><pre>    return tsResult.js.pipe(gulp.dest(‘dist/js’));<br>});</pre><pre>/*<br>Web server to test app<br>*/<br>gulp.task(‘webserver’, function() {<br>    connect.server({<br>        livereload: true,<br>        root: [‘.’, ‘dist’]<br>    });<br>});<br>/*<br>Automatic Live Reload<br>*/<br>gulp.task(‘livereload’, function() {<br>    gulp.src([‘dist/styles/*.css’, ‘dist/js/*.js’])<br>    .pipe(watch([‘dist/styles/*.css’, ‘dist/js/*.js’]))<br>    .pipe(connect.reload());<br>});<br>/*<br>copy all html files and assets<br>*/<br>gulp.task(‘copy’, function() {<br>    gulp.src(‘src/**/*.html’).pipe(gulp.dest(‘dist’));<br>    gulp.src(‘src/assets/**/*.*’).pipe(gulp.dest(‘dist/assets’));<br>});</pre><pre>/*<br>compile less files<br>*/<br>gulp.task(‘less’, function() {<br>    gulp.src(‘src/styles/semantic.less’)<br>    .pipe(less())<br>    .pipe(gulp.dest(‘dist/styles’));<br>});</pre><pre>/*<br>browserify<br>now is only for Javascript files<br>*/<br>gulp.task(‘browserify’, function() {<br> browserify(‘./dist/js/main.js’).bundle().pipe(source(‘main.js’)).pipe(gulp.dest(‘dist/js’));<br>});</pre><pre>/*<br>Watch typescript and less<br>*/<br>gulp.task(‘watch’, function() {<br>    gulp.watch(‘src/styles/*.less’, [‘less’]);<br>    gulp.watch(‘src/**/*.ts’, [‘typescript’,’browserify’]);<br>    gulp.watch(‘src/**/*.html’, [‘copy’]);<br>})<br>/*<br>default task<br>*/<br>gulp.task(‘default’,[‘less’, ‘typescript’, ‘browserify’, ‘copy’, ‘webserver’, ‘livereload’, ‘watch’]);</pre><p>As you can see we have define some tasks.<br>The <em>typescript </em>task read the tsconfig.json file and take all the options, after that gulp compile <em>typescript</em> as <em>Javascript ES5</em> with <em>commonJS</em> module, if you are brave you can establish to compile in Javascript ES6 too.</p><p>The <em>webserver</em> and <em>livereload </em>are the two tasks related with webserver for testing the web app and the automatic reload of webserver when have some changes in css or javascript files into the <em>dist</em> folder.<br>The webserver have the <em>root folder</em> into the <em>dist</em> folder and the default port is <em>8080.</em></p><p>The <em>copy</em> task simply copy the assets files, like images and the html files. in this example we suppose that html will be not compiled and is sufficient to copy into the <em>dist</em> folder.</p><p>The <em>less</em> task compile less files into css and copy into the <em>dist/styles</em> folder.</p><p>The <em>browserify</em> task is a very important piece of puzzle. after the typescript-&gt;javascript compilation, browserify create a <strong>monolithic javascript</strong> file with all the requirements. In this specific case he read the <em>main.js</em> file into <em>dist/js</em> folder, find all the requirements and recreate them into the same folder.</p><p>The <em>watch</em> task, is in charge to “watch” if the <em>less</em> files, the <em>ts</em> files and the <em>html</em> files are changed and for every specific result execute one or more tasks.</p><p>The <em>dafault</em> task is the mandatory task and execute all the previous tasks.</p><p>The last step is the tsd init process</p><pre>tsd init</pre><p>TSD is package manager for typescript. In my next post i will explain how we can connect tsd files with typescript files and how to compile them correctly.</p><p>Now is time to test our project, create a <em>src/main.ts</em> and <em>src/index.html</em> with a reference to <em>js/main.js</em> file into the src folder and start gulp.</p><pre>gulp</pre><p>If all work well you will see that now you have a dist folder and you can open the url http://localhost:8080</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ccdcbc6be1d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/pixel-heart/typescript-gulp-browserify-less-web-server-livereload-2ccdcbc6be1d">Typescript+Gulp+Browserify+Less+Web Server LiveReload</a> was originally published in <a href="https://medium.com/pixel-heart">Pixel Heart</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQLAlchemy, Google App Engine, Mysql, MAC OSX]]></title>
            <link>https://medium.com/pixel-heart/sqlalchemy-google-app-engine-mysql-mac-osx-5b5189410509?source=rss-d6b93e35c225------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b5189410509</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[google-app-engine]]></category>
            <dc:creator><![CDATA[andrea mucci]]></dc:creator>
            <pubDate>Thu, 17 Sep 2015 21:53:05 GMT</pubDate>
            <atom:updated>2015-09-17T21:56:55.542Z</atom:updated>
            <content:encoded><![CDATA[<p>In this tutorial i will show you how to install MySQL drivers for Google App Engine in your local MAC OSX.<br>After you can emulate Google Cloud SQL service in your personal MAC OSX and SQLAlchemy.<br>I suppose that you have installed correctly SQLAlchemy in your virtualenv.<br>First of all you have to donwload MySQL.<br>I have used the dmg image<br>When the installer complete the installation you have the mysql service installed and in you System Preferences you have a the MySQL Service Manager where is possible to start the demon and configure if you want to start Mysql during OSX Startup.<br>So, now is time to configure the correct user root password.<br>open you shell and type</p><pre>mysql -u root -h localhost -p</pre><p>Leave empty the password prompt<br>now you are in the mysql command.<br>Is time to change the password for root user. First you have to select the database that contain the users informations.</p><pre>mysql&gt; use mysql;</pre><p>and</p><pre>mysql&gt; show tables;</pre><p>and execute this query to return all the current installed users</p><pre>mysql&gt; select * from user;</pre><p>the result is a very confusing list of signs and words.<br>But if you pay more attention you will see all the 4 root users with the different host related.<br>So we have to launch a query that update the password for all these users:</p><pre>mysql&gt; UPDATE mysql.user SET Password = PASSWORD(‘secret_root_password’) WHERE User = ‘root’;</pre><p>Modify the <em>secret_root_password </em>with your password.<br>After</p><pre>mysql&gt; FLUSH PRIVILEGES;</pre><p>Now if you exit and login again, when the prompt will ask you the password you have to use the password configured in the previous query.</p><p>Now you have your Mysql installed and configured.<br>Is time to configure the Python application and SQLAlchemy to connect with your Mysql.<br>Before all you have to modify your app.yaml file to add the Mysql driver support</p><pre>application: your-app<br>version: 1<br>runtime: python27<br>api_version: 1<br>threadsafe: yes<br><br>handlers:<br>- url: /favicon\.ico<br>  static_files: favicon.ico<br>  upload: favicon\.ico<br><br>- url: .*<br>  script: yourapp.main.app<br><br>libraries:<br>- name: MySQLdb<br>  version: &quot;latest&quot;</pre><p>So you have to add in the libraries the <em>MySQLdb</em> driver.<br>Now configure the connection url for SQLAlchemy</p><pre>&#39;mysql://root:secret-root-password@localhost/mytestapp&#39;</pre><p>For this example we use the root user but is recommended to use another user with restricted privileges.</p><p>Go to mysql shell</p><pre>mysql -u root -h localhost -p</pre><p>and create the database</p><pre>mysql&gt; CREATE DATABASE mytestapp;</pre><p>Now you have to sync SQLAlchemy with your database engine.<br>If you don’t know how to sync a database with SQLAlchemy, please go to the documentation site.<br>Sometimes your obtain an error with the library <em>libmysqlclient.18.dylib<br></em>You can solve the problem doing a link with this library, open your command line and type</p><pre>sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/</pre><p>ReSync SQLAlchemy.<br>If all work well you can test your Google App Engine application with MySQL like Google Cloud SQL.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b5189410509" width="1" height="1" alt=""><hr><p><a href="https://medium.com/pixel-heart/sqlalchemy-google-app-engine-mysql-mac-osx-5b5189410509">SQLAlchemy, Google App Engine, Mysql, MAC OSX</a> was originally published in <a href="https://medium.com/pixel-heart">Pixel Heart</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>