What are some ways of structuring modular code

ps: I already have my own way of doing this, I was more asking around to see how other people do it

Structure is an important thing when working with ModuleScripts, I was wondering how you structure your modules when working on projects.

For example, I tend to create a few core systems, then make a folder to hold modules and a separate one for packages

If a core system works by using small blocks of modular code, ie: ObjectHandler or a closed source remote library I wrote, I end up with extra folders for those.

Here’s a simple example of that structure

    external codebases, ie: fusion

    game modules

    core game systems, ie: an object handler

    scripts for creating scriptable objects

    scripts for binding remoteevents

But anyway, how would you create a structure around modular code


I don’t really know how to explain my way of doing it, but here’s a screenshot of how I typically organize my systems. I have a CoreModules folder that contains the main modules that are called by the script that handles the system but may also be called by other scripts outside the system. Then, inside of the script that handles the system I keep scripts that are only used by that one script.

Pretty much the same as you. I call nearly everything from my “Boot” scripts that access the CORE. Anything that is specific to the game is put under ServerStorage, StarterPlayerScripts, and ReplicatedStorage.

	Assets -- Assets that every player needs on loadup
	Core -- Main module using lazy loading
		Class -- Store my OOP here
		Color3 -- Class folders for large script systems
		ObjectCache -- System ModuleScripts are uppercase
		weld -- Function ModuleScripts are lowercase
	Library -- Stores massive lists/tables

	Server -- Access and require CORE once by server (CRITICAL)

ServerStorage -- Store local assets
	Assets -- Local assets for each player to avoid loading everything at once
	Library -- Store hidden lists so player can't use hacks n' stuff to find out everything

	StarterPlayerScripts -- Store player-only scripts and GUI
		User -- Access and require CORE once by player (CRITICAL)
			-- Scripts
			-- GUI