Sure, you'll create a project using the Alfresco SDK. That will give you a Maven-based source code structure that will allow you to compile an AMP (Alfresco Module Package) that you will deploy to your WAR.
A service is just a class that is responsible for some specific operation. There are many many examples of this pattern, but here is a simple one that is easy to get your head around:
GitHub - Conexiam/alfresco-acl-templates: Facilitates the creation of multiple named Access Control ...
That's a source code project for a repository-tier AMP that does one thing: Retrieves and applies "ACL templates" on a given node. The actual service class implementation is alfresco-acl-templates/AclTemplateServiceImpl.java at master · Conexiam/alfresco-acl-templates · Git...
So you'd create an AutoNumberService.java class where your autonumbering logic would reside. It might have a method called getNextNumber() or something like that.
Then you'd also create a DocumentGenerationService.java class where your doc generation logic would reside. It might have a document called resolvePlaceholders(Map<String, Object> placeholderMap, NodeRef nodeRef) or something like that.
Of course each of these might be worthy of being in completely separate projects/separate AMP files, but that's up to you.
Finally, you'll create something like DocumentNumberActionExecuter.java that will be your custom rule action. It will leverage both of these services to actually perform the action on a document when it is added to a folder.
If this is new to you I'd recommend working through my tutorials. If you have problems, create a new post with the specifics and someone will help.