Go to the French version

Fabricius : The giant project of a little life

Intro-duck-tion

During my high school years, I discovered the communication platform called Discord, surely an useful app, where everyone can create their very own profiles, chat with others, join a community, and do great things!

Inside these communities, it isn't rare to see they are helped by bots. Automated account that do actions for you, like managing members, sending fun message, creating events, it's... rich!

One of these community I've joined myself is Red-DiscordBot (Simply called as "Red"), a community with one goal : Create a robust open-source bot that everyone can extend with a system of modules (Called Cogs). Each person that host their own instance of Red can extend it to their own liking, with what they want in their bot. The only limit being the person that host his Red, or Discord.

As such, a great community of developers started gathering around Red, and create many awesome modules for Red, from the smallest to the most ambitious ones. If you ever dreamed to catch Pokemons on Discord, you can do that with you own Red bot!

However, when a developer has a brand new idea for a module, he would finds himself having to redo the first manipulations, creating 3 files, which consists of this base:

  • A __init__.py with a setup function.

  • A info.json with information about the module and its author.

  • A file (with whatever name you like, doesn't matter) that defines what the module do, but follows a few rules (create a class, give basic information, a command, etc.).

So I, who also wanted to develop my modules, didn't particularly like creating this base manually every time: I wanted to automate this task, and so the Fabricius project began! A project template rendering tool !

'scuse me? Project templating?

A project templating engine boils down to a simple thing: Create from the basis of a project, a brand new, working project from information supplied by the user.

Basically, you create a layout, retrieve information, populate with user's information, and create a new project! All that's left is to do what you want with your working project!

What about existing tools?

Red was coded in Python, so developers were used to Python tools such as black, isort, mypy, etc. It was logical to create a Python tool.

Regarding templating engines renderer, it boils down to two tools:

  • CookieCutter

  • Copier

CookieCutter is definitively the most popular, with its 20,000 stars on GitHub, however, there's a few problem with this one:

  • It's poorly maintained.

  • Doesn't allow for validation/modification of user's input (which, yes, can be extremely useful).

  • It's not customizable.

  • It crashes a lot and doesn't feel trustable enough.

  • It forces you to follow a certain pattern for your layout.

Even if I tried this tool, I couldn't use it because... Well it just doesn't work at all!

and then comes Copier, however, that one looks incredible by itself: It's maintained, feels robust, and is dang customizable!

The reason why I didn't use this tool instead, is because I wanted to test myself and create a new challenge: I wanted a new tool, one that was like CookieCutter, but even better, a universal tool that would even render CookieCutter projects!

But why, you might ask? Because everyone, who once used CookieCutter, might not want to change for a new tool, they would prefer using the same they use because they've already been using it! HOWEVER, if you've provide the same fonctionnalites with a better tool, there is a much better chance you interest peoples!

I also wanted to take inspiration from the AdonisJS's template generator, which, to me, looked just awesome and showed my vision for Fabricius! I wasn't just creating a simple tool, but an extendable tool! The Jack of all trade!

For the development of Fabricius, I decided to put myself a few constraints to respect, but also complex, for the better:

  • To be a 100% working and tested tool.

  • Extendable with plugins.

  • Must respect user's security (Unallow malicious scripts or unauthorized execution).

  • Must be fully typed.

  • Must be future-proof: Easy to add code, modify it, etc.

  • Respect a folder structure that makes it clear what you're coding.

Technical information

Fabricius started in July 2022, at this point, the last minor version of Python was the 3.10, but a few months later, the 3.11 version would come up, adding a few nice things I was interested into, and most importantly, new typing tools for the langage's typing system.

As of today, Fabricius is being worked on with the 3.12.0 Python version, a version that introduce a new syntax for generic classes.

Fabricius is still a work in progress, most of the time is put into how the project should look like, how it must feel like, what's its philosophy, what I should respect, etc..

It's really important to think about this as soon as possible, as Fabicius is meant to evolve in the future, and it includes a ton of things in one single package:

  • Create a resistant CLI tool that won't let you down (Made with click and rich and assisted by aspreno and clickloader).

  • Create classes to represent objects : Files to create, projet to build, etc.

  • Render template with the user's given information (Made with jinja, chevron, str.format and string.Template).

  • Allow a plugin system (Based on the concept of observers/listeners).

  • Reimplement project rendering of templates made with cookiecutter.

  • Be able to register user's settings in a persistent file (Made with platformdirs and pydantic).

To make all of this in one package, that's a LOT of work! Most especially when you try to respect a structure that itself, hold a certain philosophy.

My resources

…but as always, in development, we're never alone ! With such big project, I have the luck to have learned about useful resources and awesome peoples that would help me out:

Refactoring Guru

This website is just AWESOME, to anyone who wants to learn how to refactor their code, on how a program can behave, be structured or be created. Be sure to find this website very helpful whenever you try to create a new project and would like to make things as clean as possible.

Thanks to this website, I was able to understand and learn about new patterns in programmation, on top of the one I was already using myself, but blindly.

https://refactoring.guru/

Fluent Python, by Luciano Ramalho

Luciano Ramalho is a member of the PSF (Python Software Foundation), so he's definitively one of the best person to tell you about the most specific stuff in Python, and that's what his book does. Fluent Python is the resource that helped me understand the design behind Python and how to take full advantages of its potential, like magic functions!

Red-DiscordBot

The community I owe everything.
Thanks to this community, drived by friends from all over the world, they helped me and pushed me to program, and be who I am today, but also who I want to be for the foreseeable future. Red has so many wonderful peoples, so awesome that they helped me achieve things I thought I would never be able to tackle down myself.

I especially thank Jackub Kuczys (aka. Jackenmen) (Main contributor of Red-DiscordBot), Danny (aka. Rapptz) (Creator of discord.py), MAX (Contributor), Logan Brown (aka. NeuroAssassin) (Contributor), Thusuzzee, aikaterna, and everyone else from the community for being the nicest community, and the most knowledgable community I've ever met.

https://discord.gg/red

Well... That's a great explanation of my project...

I hope you liked my writing, hey, I like writing! So it was fun!

I'll make Fabricius, promise, this tool will exist at some point. When? Idk :)