Hi Darius.

On Thu, Jun 27, 2019 at 1:10 PM Darius Blaszyk <dhkblas...@gmail.com> wrote:

> Hi all,
>
> I have been asked to write a limited functionality / mini ERP type of
> software for an NGO that is setting up a hospital. I'm doing this in my own
> time and free of charge. The compiler and IDE of choice are of course
> FreePascal & Lazarus. I’m still thinking about the direction to go exactly
> with this and I was hoping to get some feedback/support from the community
> here as I always have gotten over the years.
>

First of all, good luck in your project! :-)

The hardware of choice is already made and will be a network of several
> Chromebooks on which all staff will be logging in the system. This made me
> think that a desktop application is less feasible and I should look at a
> web-based solution. I found some frameworks such as ExtPascal, fano, Brook,
> pas2js. Unfortunately, I don't know much about web-based applications. So
> my question is whether any of the frameworks are mature enough to create a
> database driven application as described. Possibly there are other
> frameworks available that I don't know of but are worth investigating?
>

There is an important project also for web/database purposes missing on the
above list: mORMot. You should consider to investigate it too. :-)

Regarding Brook, there are two active versions of it:

1. https://github.com/risoflora/brookframework
2. https://github.com/risoflora/brookfreepascal

Let me explain starting from option 2, BrookFreePascal, which I'm going to
reference as B4F. As Michael commented (thanks dude! :-)), it is a
long-standing FCL-based project, providing high-level features making it
easy to develop FPC/Laz web applications. It was strong influenced by Slim
Framework, also active nowadays and, like Slim, B4F uses a basic routing
concept, which triggers predefined methods named as the same HTTP verbs,
like Get, Post, Delete etc., declared in the public scope of an action
class. The few lines below illustrates it:

...
  THello = class(TBrookAction)
  public
    procedure Get; override;
  end;

procedure THello.Get;
begin
  Write('Hello Darius. I'm Brook on the Chromebook! :-)');
end;

initialization
  THello.Register('/hello');
...

If you run a Brook application containing these lines above, just navigate
to "/hello" to get the message "Hello Darius. I'm Brook on the Chromebook!
:-)" on your web browser and have a lot of fun.

Now, I'm going to explain the option 1 a bit, the new Brook Framework,
under active development, projected for Free Pascal and Delphi, which will
be referenced in next lines as BF. It was entirely written from scratch
with special care for embedded systems. BF routing was and is still
inspired by projects like Express, Flask, Laravel, and its components
follows some RAD concepts adopted by DataSnap/fpWeb. For example, if you
have a console or VCL project, you can turn it into a web server
application: at design time, just drag-drop three components (
BrookLibraryLoader1, BrookHTTPServer1 and BrookHTTPRouter1) to a form or
data module, define a regular expression pattern for a route item and
implement its request event:

... [.lfm or .dfm]

  object BrookHTTPRouter1: TBrookHTTPRouter
    Routes = <
      item
        Pattern = '/hello/(?P<name>[a-zA-Z]+)'
        OnRequest = BrookHTTPRouter1Routes0Request
      end>
  end

... [.pas]

procedure TForm1.BrookHTTPRouter1Routes0Request(ASender: TObject;
  ARoute: TBrookHTTPRoute; ARequest: TBrookHTTPRequest;
  AResponse: TBrookHTTPResponse);
begin
  AResponse.SendFmt('Hello %s', [ARoute.Variables['name']], 'text/html',
200);
end;

...

This way, if you navigate to "/hello/Darius", the message "Hello Darius"
will be displayed on the browser, however, any other invalid value, like "
/hello/*123*", will be automatically refused, due to pattern "
/hello/(?P<name>[a-zA-Z]+)" defined to the route item.

There are a lot of features (three threading models, data compression,
on-demand content, JIT optimizations, etc.) with focus on performance that
I couldn't detail in a single message, but the most important info: BF
loads a GNU C library which provides a low-level API containing common HTTP
features that are a good replacement for HTTP servers like Apache, Nginx,
NodeJS, Civetweb and so on. In short, you can run your application in
production and provide web services in the same (or higher) performance as
those servers, just distributing a small single-file library with your
executable, that probably will already be using other library, like the
database client one, for example.

As I am starting this endeavor I would welcome any advisory or practical
> help. If someone is willing to support in any form, please contact me via
> PM.
>
> TIA for all pointers, tips, and suggestions.
>
> Regards, Darius


I'd like to make a naive suggestion for you regarding to server side. You
mentioned about several Chromebooks logging to the system. So, beforehand,
what do you think about simulating that scenario? It is a little bit easy
to do: there are tools like wrk, JMeter, ApacheBench etc. you could use to
trigger several requests generating reports by itself like those ones
<https://github.com/risoflora/libsagui/tree/master/examples/benchmark>.
IMHO, it could be a reasonable way to choose the proper package/server to
serve your requirements.

-- 
Silvio Clécio
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to