<?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 Michaël Villeneuve on Medium]]></title>
        <description><![CDATA[Stories by Michaël Villeneuve on Medium]]></description>
        <link>https://medium.com/@michalvilleneuve?source=rss-696b87fba5e6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Laoy9eUIsdj3HD0ZtvwwZQ.jpeg</url>
            <title>Stories by Michaël Villeneuve on Medium</title>
            <link>https://medium.com/@michalvilleneuve?source=rss-696b87fba5e6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 19:09:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@michalvilleneuve/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[GDPR, how it affected FidMe’s back-end]]></title>
            <link>https://medium.com/snapp-fr/gdrp-how-it-affected-fidmes-back-end-8710024abf1c?source=rss-696b87fba5e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/8710024abf1c</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Michaël Villeneuve]]></dc:creator>
            <pubDate>Thu, 21 Jun 2018 14:54:05 GMT</pubDate>
            <atom:updated>2018-06-22T12:45:25.791Z</atom:updated>
            <content:encoded><![CDATA[<h4>A journey into our service-oriented architecture</h4><p>These last few months GDPR imposed many changes to most of the apps we daily use. Hopefully, one of these app is FidMe.</p><p>If you use FidMe, you probably noticed the most obvious change : a large popup, asking for your consent regarding data usage. Beside this change, we have decided to take a deeper action on privacy by providing many tweaks and features for users to control their data usage and more.</p><p>We will focus here on one of the most <em>-programmatically-</em> interesting features we have added since GDPR.</p><h3>The &lt;Delete my account&gt; feature</h3><p>Now you must be wondering how the hell we managed to live without having a “delete account” button since then…</p><p>I also wondered that when I started working on it. First off, let’s remind ourselves<strong> </strong>that <strong>most websites and apps only make you believe that you can actually delete your account.</strong></p><p>In reality, for many reasons (historical, financial, etc) this feature is often limited to removing the ability for the user to login.</p><p>This is called <strong>“soft delete”</strong>, and in code it often translates to something like that :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*tiB1Fp4xNDPO_JR9ou5Irw.png" /><figcaption>Basic ruby example of a “soft delete” feature</figcaption></figure><p>Only users for which deleted_at property is nil have the ability to login.</p><p>As you might have guessed, <strong>this does not actually delete any user’s data.</strong></p><p>With FidMe, our goal was to provide the user with the ability to actually remove its data from our servers. Meaning :</p><ul><li>Any field containing private information has to be deleted</li><li>Any traces of his actions must be deleted</li><li>Loyalty cards, photos of receipts, user information, emails, everything must be deleted</li></ul><h4>Here comes the challenge…</h4><p>To give you an insight of our back-end architecture, here is the list of our main services:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*azqbwkatC1FcemLBbO3cyQ.png" /><figcaption>List of FidMe main services</figcaption></figure><p>Some of these services even have sub-services.</p><p>That makes a list of approximately 30 services working together to make FidMe app work.</p><p>Having a large number of services is useful in many ways. But some trivial tasks in appearance, such as deleting a user account, can become a real challenge in a decentralized architecture.</p><p>Instead of querying a single server to delete a user account, here is the flow we had to introduce :</p><ul><li>The <strong>Consent</strong> service (the one in charge of privacy) is asked to delete a user and it will follow this demand to all the other services, here is the schema</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*m32BDeQdtYv7i3u3et9mDw.png" /></figure><ul><li>In detail, a <strong>DeletionRequest</strong> is created on the <strong>Consent Service </strong>in a “pending” status. Meanwhile and during a 1 month period, the user receives a few emails reminding him that he can still cancel his request.</li></ul><p>These reminder emails are triggered by a background task, we then send them synchronously :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*Hyi1cZWVMI4kQQQdcBpiZQ.png" /></figure><ul><li><strong>The 1 month period expires</strong>. A deletion background job is created for every expired and not canceled request (we call them “due for deletion”) :</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*5SEtHBZD0dcoRpXFryC2fw.png" /><figcaption>The rails task creating deletion jobs</figcaption></figure><ul><li><strong>The job is triggered</strong>, cleaning process starts.</li></ul><p>In order to remove data from each service, we introduced the notion of <strong>Cleaners.</strong></p><p>A <strong>Cleaner</strong>, is a class that is supposed to hold the behavior related to the “cleaning” job of a single service.</p><p>Here is what we do then :</p><ul><li>We call every cleaners, here is the most simple example, the one in charge of deleting user’s receipt photos</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*apAhPUyp_WvTQjRFgzyy4A.png" /></figure><ul><li>They dispatch any associated HTTP request required to complete the deletion</li><li>If any cleaner fails, we retry a few times, otherwise we store the reason in an upper layer</li></ul><p>This main <strong>Runner</strong> class, the one that is responsible for calling each independent <strong>Cleaner</strong> is called by a Rails <em>ActiveJob</em> that is in charge of handling retries and failures.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*fssyibOhDdONaInYCd0MSQ.png" /></figure><p>By moving our code away from the active job itself, we add more abstraction to our manager. It becomes easier to test, easier to call again in case of failure, and gives us the freedom to move away from Rails if we feel like it.</p><p>That’s it for the job of the Consent service. Or is it?</p><p>Well, it has called every service, it gave them the responsibility to handle the deletion themselves. Hopefully they have done their job. Everything is fine.</p><p>Except one thing. Considering that the <strong>Consent </strong>service is responsible for the user’s deletion, it would just feel natural if it has a bit of control over it.</p><p>Of course, it is up to each service to know the behavior and logic required to delete a user account. But this entire feature felt very close to the main <strong>Consent</strong> service.</p><h4>So, we split our services in modules…</h4><p>Adding the deletion behavior to each service is now pretty straightforward.</p><p>Each service must implement more or less logic to delete user’s data, but in general it can be as simple as deleting things in cascade</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*TPIQxJmj6vWZiNvmgQl-oA.png" /></figure><p>But when there is more behavior required, for example when we have to delete images, logs, complex destructured things in our database, we don’t want to “pollute” our service’s code with deletion related code.</p><p>So we thought, let’s make a module !</p><p>Our stack being very rails oriented, we have what is called “engines”. An engine is a sort of Rails plugin that adds/override any behavior of a Rails monolith.</p><p>The plugin being a Gem, all you have to do is add it to your Gemfile.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/178/1*CEqgEAxKz7VPJBsUK9iNQw.png" /><figcaption>After the dedicated service, the dedicated gem</figcaption></figure><p>At this point, we needed to add methods and behaviors to each main Rails application in order to handle <strong>Consent HTTP request.</strong></p><p>To follow up on the above general schema, here is the detailed redundant process for each service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*P8r_XZ9_70H3z7HR_edBuA.png" /></figure><p>And in this process our newly created engine adds the entire logic to the initial service :</p><ul><li>It adds the correct route :</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*tHFcp9faowKt6ixL42K0tQ.png" /></figure><ul><li>Which leads to a new controller with its own Authorization strategy</li><li>And of course, the service holds the logic that deletes everything</li></ul><p>All of the database’s related deletion is done transactionnaly in order to avoid and catch any potential error.</p><p>In the below example, we call our “Anonymizers” which are in charge of… guess what… <strong>anonymizing</strong> the data that can’t be completely destroyed. The whole thing is processed in a transaction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*kuN0ASZhRQKXe3IUxJ16eA.png" /><figcaption>Calling each Anonymizer in a transaction</figcaption></figure><h3>So far…</h3><p>Our special insight into our service oriented architecture is over !</p><p>Even though it is not the point of this post, I feel that I should write a little about my feelings regarding our architecture.</p><p>So far, even if service oriented adds complexity, we reach a level of decoupling that is extremely high and pleasant.</p><p>I think it is the most important thing here. Given that our server load has increased over the years, we managed to keep our heads clear of all the complexity by working on very small and decoupled fragments of our application.</p><p>This is extremely important for us, and for our new developers. We are really hoping that they will be able to quickly grasp the problematics of the projects we make them work on.</p><p>By the way, if you are interested in joining us and working with us on our back end architecture, <a href="/service/mailto:jobs@snapp.fr">we would love to hear from y</a>ou. Do not hesitate to give our <a href="https://github.com/FidMe/jobs">small back end challenge a try !</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8710024abf1c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/snapp-fr/gdrp-how-it-affected-fidmes-back-end-8710024abf1c">GDPR, how it affected FidMe’s back-end</a> was originally published in <a href="https://medium.com/snapp-fr">Snapp&#39;</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lessons learned while integrating React Native into FidMe]]></title>
            <link>https://medium.com/snapp-fr/lessons-learned-while-integrating-react-native-into-fidme-b7f0ece74c7f?source=rss-696b87fba5e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7f0ece74c7f</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Michaël Villeneuve]]></dc:creator>
            <pubDate>Wed, 07 Mar 2018 15:36:19 GMT</pubDate>
            <atom:updated>2018-03-07T15:36:19.630Z</atom:updated>
            <content:encoded><![CDATA[<h4>Estimating the changes to come</h4><p>When we started working on adding React to our existing native app, we already had a <a href="https://www.snapp.fr/developpement-dapplications-mobiles-react-retour-dexperience/">first experience</a> on the matter.</p><p><strong>Our first try went pretty well</strong>. It was all about adding a completely separated part to an existing app.</p><p><strong>Almost no communication between native and JS was necessary. </strong>This very simple flow made it extremely easy for us to plug React Native as a side module.</p><p>On <a href="https://www.fidme.com/fr">FidMe</a>, the idea was to <strong>add several React bricks among the whole app. </strong>Some views would be integrated among existing native views/fragments (the “Marques” tab on the left below), others would just popin seamlessly during existing native workflows (ticket scanning).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aX2iI-RXxr6rIF93AxdLcw.png" /><figcaption>One of our React Native flows in FidMe</figcaption></figure><p>In theory this would allow us to <strong>iterate much more rapidly</strong> on new views as they would be shared between Android and iOS.</p><p>Unfortunately <strong>we underestimated the number of bridges necessary</strong> to communicate properly between native and react.</p><h3>Communicating between native and React</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0dYrmYqf27ztj-oitbxJ8g.jpeg" /></figure><p>There are many ways to communicate information among your app. But when it comes to passing information back and forth between native and React, you do not have so many options, so be careful when choosing.</p><p>We narrowed down the options to the three following :</p><h4>Choice n°1 : Passing information on startup</h4><p>That is the way we chose for the majority of our API calls. It is <strong>very convenient</strong>, you only need to instantiate your react part with default props :</p><pre>let mockData:NSDictionary = [&quot;token&quot;: HTTPCaller.accessToken as AnyObject, &quot;serverURL&quot;: Constants.Network.serverURL]</pre><pre>let rootView = RCTRootView(</pre><pre>    bundleURL: jsCodeLocation,</pre><pre>    moduleName: &quot;YourReactModule&quot;,</pre><pre>    initialProperties: mockData as [NSObject : AnyObject],</pre><pre>    launchOptions: nil</pre><pre>)</pre><p>Do the equivalent in your Android app, then you can just <strong>access this information as props on your root component</strong> :</p><pre>const { token, serverURL } = this.props; // We store these as properties of our API classes</pre><p>We think that <strong>this is the way to go</strong> if your use case can adapt to it. It allows you to just fetch() data normally from your API, while automatically adapting to server Url, language, etc.</p><p>A perfect use case would be developing a <strong>completely separated part </strong>of your app with React<strong>,</strong> meanwhile calling the same server as the rest of your app, but different API endpoints.</p><p>It <strong>consumes very little time</strong>, gives you a lot of flexibility in JS and is probably the less hard to maintain<strong>. But few use cases can rely only on it.</strong></p><h4>Choice n°2 : Re-developing an entire API call process for JS parts</h4><p>That way is probably the less efficient in terms of code duplication.</p><p>But still, no bridge will be necessary, meaning <strong>your JS developer will never need to ask anything to the Android/iOS developer.</strong></p><p>One potentially huge drawback is that you will have to maintain the same API call in <strong>3 different languages.</strong></p><p>A good use case I can think of is if you want to replace step by step your native views with React ones.</p><h4>Choice n°3 : Create bridges for all your API calls</h4><p>In some use cases, you may need to keep the webservice logic in native only. Many reasons may force you to do so :</p><ul><li>Lots of things to bridge in order to achieve a single API call in JS</li><li>Use of old or in-house communication protocols</li><li>Too strong dependency on the webservice in native parts</li><li>Offline mode, callbacks, cache you may have added to your native calls (this was the case in our project)</li><li>Architecture that prevents you from exposing sensitive information (token, auth infos) publicly in your classes (this was also our case)</li></ul><p>When you encouter one of these cases you might want to choose this solution.</p><p>You will <strong>not bridge information</strong>, you will <strong>bridge your entire API</strong> calls suite.</p><p>You will end up with classes with lots of bridged methods like this one (android example).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/554636f187dec0834be87c57eaa009f6/href">https://medium.com/media/554636f187dec0834be87c57eaa009f6/href</a></iframe><p>Notice the @ReactMethod annotation that allows to expose this method to React’s NativeModules.</p><p>This method allows us to update user information in JS like this :</p><p>CustomerAPI.updateInfo({ firstname, lastname }).then(doSomething);</p><p>It ends up being very clean on the JS side.</p><p>The best way to make this work properly is to ensure that<strong> Android and iOS </strong>developers have very <strong>consistent and similar ways of calling your API.</strong></p><p>Whether you choose the first, second or third option, you need to very <strong>carefully think about it.</strong></p><p>Our mistake was to underestimate the importance of consistency between calls. In short :</p><ul><li>As a JS developer,<strong> </strong>always <strong>involve both Android and iOS developers</strong> when choosing a solution</li><li>Keep it <strong>consistent among your entire app</strong></li><li>Think about maintainability and scalability of your bridges as they may be <strong>hard to test</strong>, hard to update, and <strong>yet crucial</strong> to your app</li></ul><h3>Back and forth navigation between native and React</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/1*tdeupKxvMkOnMf4wNHcAfQ.jpeg" /><figcaption>Back and forth may be hard to deal with</figcaption></figure><p>It think that this is a potential major source of time loss. In <a href="https://www.fidme.com/fr">FidMe</a> we had several workflows that required to switch between existing native views and react views.</p><p>In our mind that would not be a problem, we would just pop a native screen, then dismiss it, then pop a React view.</p><p>But it has not been that simple.</p><p>When poping in a native screen, you <strong>interfere</strong> with the current react navigation stack. You add a native screen on top of it, and in our case this screen was not pushing an entry in our navigation stack.</p><p>In the end, we chose to use React Navigation and redesigned the header to match the native ones. It works ok, it is easy to customize, plus documentation is good, performance is correct and native feeling is ok.</p><p>But our solution to manage switch between React and Native is <strong>not perfect. </strong>Everytime we switch from native to react, we re-instantiate an entire React flow, with its custom entry point. It works fine, but we encounter something like 100ms delay when switching. It may be a problem in the end.</p><h3>Spend time working on your project configuration</h3><p>Misconfigurations of your React integration may cause issues such as : hot reload not working, conflicts with native libraries, dev menu not working, JS debugger not working, slow startup etc, etc.</p><p>We think that <strong>spending time creating a clean configuration</strong> of your project is one the <strong>keys</strong> to being satisfied with React Native.</p><p>Just to make a quick fix, you may be tempted to leave that non working debugger aside. But unless you really don’t have time for that, <strong>do not</strong> let these small issues <strong>ruin</strong> your productivity.</p><p>Furthemore, your native developers who continue to work on the initial project <strong>may not want to be bothered by the React integration.</strong> Try to <strong>simplify the build process</strong> for them, write documentation on how to install the app with React, show them, and explain to them how the whole thing work, otherwise you <strong>may end up upsetting them.</strong></p><h3>Do not expect to work twice as fast as an average</h3><p>The process of creating views with React Native has always been something kind of magic. People often demonstrate React Native power just by showing off “Hot reload” features, or pixel perfect compatibility between Android and iOS.</p><p>When considering only these exemples, you may end up thinking “Ok, we will be twice as productive as when writing native apps ! That’s great !”. Yeah, but, not always…</p><p>When developing simple, “Javascript only” apps, you may reach a very high productivity, sometimes even higher than twice as fast compared to native. Views build themselves just as you type, it really is amazing.</p><p>But in a real life app, and if your product needs very specific things, you will eventually end up making native code, bridging things. The time you gained with hot reload may be compensated by the time you will spend resolving conflicts between libraries, building native code, bridging views, etc.</p><p>It is probably an illustration of React Native’s immaturity but because of its rapid changes, some third party libraries may not always work, may have compatibility issues, and fixing them up, or adapting them for your need is very time consuming.</p><p>On an average Javascript only app, we estimated an overall <strong>1.6x faster</strong> than developing for both iOS and Android. On <a href="https://www.snapp.fr/casclients/cas-fid-me/">FidMe,</a> because we had a lot of bridges and custom flows, we estimated that we would have needed roughly the same time.</p><p>But one thing to consider, is that updates, new features, etc, won’t require more time to make bridges and we are hoping to reach the desired 1.5x faster goal sooner or later.</p><p>In the end, we are very satisfied by our React Native integration.</p><p>Not everyone at the same scale of course. But considering the fact that at <a href="http://snapp.fr/">Snapp’</a> we are surrounded by <a href="https://github.com/Snapp-FidMe">native developers</a>, <strong>we basically have no limit to what React can do for us.</strong></p><p>Anything can be bridged, any performance demanding thing can be done natively and <strong>mixing native and JS is easily achievable.</strong></p><p>If you feel confident writing JS and you have native developers by your side, <strong>React Native cannot be a bad choice</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7f0ece74c7f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/snapp-fr/lessons-learned-while-integrating-react-native-into-fidme-b7f0ece74c7f">Lessons learned while integrating React Native into FidMe</a> was originally published in <a href="https://medium.com/snapp-fr">Snapp&#39;</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>