InvoiceMall - SaaS Billing Service for Studios and Freelancers

    invoicemallHello! My name is Ignat. I am an employee of CloudMill, the company that developed the InvoiceMall customer relationship management service . This article is the first in a series of materials that will talk about him. In this article, I will address the issues of the technical part of the project implementation, I will talk about the technologies used and the development process. The following material will be devoted to the use of service with invite keys.

    Initially, the service was created for the needs of our company. Over time, we decided to expand its capabilities somewhat, using the most successful ideas that appeared as a result of a brainstorm and analysis of the work of competitors. It took about two months to develop the concept. We have collected all the best and created a unique service that has ample opportunities.

    The basic functionality consisted of a billing service and a customer base. As a result of painstaking work on the project, the following additional functions appeared:
    • customer management;
    • project management;
    • account management (various statuses and types of accounts);
    • cost management;
    • ticket system;
    • archive of documents;
    • statistics;
    • the ability to accept payment to the internal account in the system through various payment instruments.
    We are developing a few additional sections that will make our service a complete CRM system. In addition, we plan to introduce social services and multi-language functionality. All of the above functions will be connected as modules, depending on the preferences of our customers. Thus, we will maintain the simplicity of the service for those of them who only want to create accounts in our SaaS project.

    Other SaaS services at work.

    We were always interested in how other teams work, so let's talk a little about ourselves. Initially, we used BaseCamp, but for some reason we soon abandoned it. After a long process of choosing from various project management / collaboration services, we switched to the following:
    • dropbox.com - File storage and backups;
    • beanstalkapp.com - GIT & SVN repositories;
    • lighthouseapp.com - Ticket system.
    Iron and Hosting

    For two years now we have been customers of The Planet. At the moment, we rent three servers:
    • 2x Intel Xeon QC 2.0GHz, FreeBSD 8.0, MySQL 5.1.50, not accessible from outside, 12GB of RAM;
    • 2x Intel Xeon QC 2.0GHz, FreeBSD 8.0, memcached / MongoDB, not accessible from outside, 12GB of RAM;
    • 2x Intel Xeon QC 2.0GHz, FreeBSD 7.2, nginx 0.8.48, PHP 5.3.3 fastcgi (FPM).
    This is quite enough for hosting our customers and for the functioning of our project. We initially abandoned the Cloud for a number of reasons:
    • firstly, it’s a terrible Amazon` SLA;
    • secondly, the prices when using such resources will not be much lower.
    However, we use S3 & CloudFront (CDN) to store and distribute content. We are now setting up the infrastructure at Hetzner to transfer InvoiceMall to a site in Germany. This will reduce latency from 220ms to 70-80ms. We are also considering options for using MDNS (Zerigo), for an even faster response.

    Safety

    We paid a lot of attention to the safety of the project. For this, the framework has been redesigned. Now all incoming data is pre-filtered and cleaned, which avoids possible mistakes of developers. In addition, all data that falls into SQL queries is also cleared. Our next step will be to connect the CSRF protection to the forms.

    We really encrypt backup tables before sending them to the archive server once a day. The software is constantly updated. In addition, we carried out internal server optimization. Included ipfw and autobahn bots. The server and network load are constantly monitored.

    Thanks to all this, we can sleep peacefully without waking up at three nights from angry calls complaining that the server is not responding. We don’t need to rack our brains on how to climb on it and defeat the DDoS attack.

    Software

    As it became clear, the service is written in PHP. We use our own framework based on Kohana 3.0. It has been heavily rewritten. It can only be launched in PHP> 5.3, it definitely needs memcached and mysqli. We also abandoned the Kohana’s View model by connecting the H2O template engine, which in turn underwent strong correspondence. Twig fell away, losing in H2O performance. ORM was excluded, and sessions and authorization were rewritten with it. An ORM exception is a necessary measure because All requests are profiled and optimized.

    All framework code was profiled. We tried to optimize everything in our power to remove repeated calls to functions, pass cycles, transfer content.

    As a result, we reached a maximum page generation time of 0.007 seconds and a memory consumption of 800kb using APC and multi-level caching (tests were conducted on the production service).

    When deploying a new version, a script is launched that combines the framework into one file. Logging and queues go to MongoDB, which allows us to safely scale the project. At the moment, we do not plan to switch to NoSQL.

    A few words about architecture

    After our decision to make the product public and analyze the capabilities of competitors, we began designing the service for hundreds of thousands of users. Various fields, types of invoices, predefined settings and much more were laid down depending on the selected country. All text was removed from the templates and scripts and moved to language files, which are always accessible from the cache. Thus, the only thing required to add a new language is to add its language files, the system will connect it itself.

    Features

    authorization on invoicemall
    Authorization with us is possible through Yahoo, Yandex, Google and Google Apps. Soon we will connect FaceBook. We do not use OpenID (the logic of work is slightly different). Authorization will occur only if you are already registered with this email.

    authorization on invoicemallCurrently implemented import contacts through Google AuthSub. You just need to click on the button, confirm the permission on the site and select those you want to add.

    Both classes (OpenID, oAuth) have our own. One Janrain connection added almost 0.3 s. to run and increased memory by 1mb. It was pointless to refactor, therefore, for each service its own wrapper was written. The base class took OpenID from ZF.

    HTML / JS

    The JS framework is a well-known jQuery, for the beta period, we do not optimize or compress CSS. In the future, a script will be written that will upload to CloudFront both the source code and the gzip version that have previously been optimized.

    The project implements partial support for IE6. For example, there are no rounded corners in it, but nothing floats and the scripts work as needed. We also optimized javascript so that loading and all actions with the DOM occur without delay on all browsers. In the future, we plan a full transition to HTML5 and the abandonment of support for IE6.

    API

    We are currently working on an API. Each function on the site will be available through the API. It will be a simple and easy way to integrate. For example, using our service in the operation of your store will allow you to set beautiful accounts, keep convenient statistics, do marketing mailings to customers and accept payments through various merchants. We will try to limit the use of the API only to your imagination.

    On this I will end. We will be happy to answer all your questions and provide invitees for testing our product. We ask you to treat possible errors with understanding, but we believe that with your help we will be able to quickly, and most importantly, in the right direction complete the beta testing phase and come to the release with confident steps.

    Regards, CloudMill Team

    Also popular now: