Building only with the needed packages

Hi there
I have this router with a usb port were i attache a wifi dongle(wlan1) that is connected to a wifi network. It gets a dynamic address from the wifi network.

wlan1 is set as wan port

and the 4 ether ports and the internal wifi (wlan0) of the router are on the same bridge with local dhcp enabled.

i wanted to build the stable release with only the bare minimum for this setup.
So no luci, never used it, all config is done from terminal, no pppoe ipv6 and stuff like this.

Can someone point to what packages i can remove and what must be preserved for this config.

Thank you

https://lede-project.org/faq/before_installation#which_packages_can_i_safely_remove_to_save_space

I'd suggest you look at lede image builder. Start with default lede packages for your router and iteratively remove packages from the build untill you get bare minimum for the functionality you need.