FreePBX architecture

Hello guys,

I have been working with Asterisk for many years but just started looking into FreePBX for one of my work.
Basically I am interested in knowing FreePBX core architecture, how it interacts with Asterisk and Database.
I did search on forum and found this post where tonyclewis said

FreePBX writes everything to a database tables. Then when you run the Apply Config from the GUI it takes everything in the database, writes out .conf files and reloads asterisk.

Is there any other details available on architecture other than this?


P.S. I’m a new user and hence not allowed to put any link in my post.

New to the team and project, but this seems to be very much the case. I will say that the core of FreePBX is made up of many modules, each can be found in their own git repository. All of these modules are protected with signatures, so any updates needs to be signed to protect the module from being tampered with. It does take a bit of time to wrap your head around.

There are few other tools you can use defined here including dev tools:

Module Signing:

Big Module Object (BMO) is also something worth mentioning:

BMO provides provides methods to install, upgrade, remove, backup, handle AGI, among other things for a module.

Thanks Matt,

Not exactly what I was looking for but those links are useful in other ways.

I’m not aware of any detailed documentation, but it is all open source. You could start by examining the code for a very simple Application, such as Misc Destination.

For links, I recommend putting them on a line by themselves, replacing the last for with %2E e.g.

On a mobile, this works as a link. On desktop, triple-click to select it, then right-click and choose Go to …

Can you be more specific in what you are looking for?
I spent over 5 years documenting development in FreePBX. It is all in the wiki.

Are you looking for how to recreate it?

Generate appropriate dialplan including AGI scripts. Use the asterisk manager interface for more direct interactions.

You can do these same things without BMO. The difference is that BMO introduced object orientated code into freepbx. Before you’d have to write procedural code to do install upgrade remove backup agi through The bad thing about is that they are loaded for every module on every freepbx run (page laid. Scripts. Etc). Since BMO is object oriented that means it can take advantage of auto loading. So module functionality is only loaded when requested instead of each request. This means lower memory footprint and faster performance :slight_smile:


Thanks James,
Let me add some more details. As I have learned so far there are different components in FreePBX like Web interface, Asterisk(possibly AMI somewhere!), Database, some scripts running in background, etc…
I was interested in knowing how they communicate with one another and in which order.

Further, as tonyclewis mentioned here

FreePBX writes everything to database tables. Then when you run the Apply Config from the GUI it takes everything in the database, writes out .conf files and reloads asterisk.

Does FreePBX take all the configuration from the database and write to config files or just the part/s that has/ve been changed on GUI?

I had come across this wiki page, but it explains nothing about the components.

OT, I’m not a web developer and hence asking, is there any way to map FreePBX tables with GUI without going through PHP code?

This is an inaccurate statement. Not everything is written to a MySQL(MariaDB) database table. Some settings are only stored in the AstDB and some, like voicemail, aren’t even saved anywhere but the actual config file. Voicemail, for example, will just parse the voicemail file and then re-write it when things are saved.

That being said, there is no documentation to tell you that or to tell you what the actual DB structures, tables or schema’s are for those tables. There’s nothing that lays out things like Extensions use findmefollow, users and devices tables but only certain FollowMe or other settings are written to the SQL tables but some settings are only written to the AstDB database.

There also nothing that tells you the relationship of the SQL data to the AstDB data. For example, for FollowMe the “Use Call Confirmation” has the field of ‘needsconf’ in the SQL database that has a value of NULL or CHECKED (enabled) but in the AstDB which is checked via the dialplan the field is ‘grpconf’ and the values are empty (nothing set) or ENABLED. So you can’t count on an exact one to one relationship of what is in the SQL tables and what is written out into the dialplan/AstDB.

There is also nothing that covers what other modules impact user settings/details in the AstDB. Queues, Extension Routes, Parking Pro and I’m sure others all write information to a users AstDB profile that is called on via the dialplan or other actions.

I spent quite a bit of time just modifying settings in the GUI and then checking those changes against the dialplan, config files and AstDB to see exactly what was being done and the final results to figure out what is related to what.

1 Like

That’s a great explanation Tom. I appreciate it.
I’ll dig deeper to figure out that from code itself.

Thanks again.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.