Making your own DEX

Hi everyone, i had this idea for a new liquidity pool design. I already have some Solidity programming experience. What i want to do is basically my own decentralized exchange (DEX), with a generic liquidity pool contract for Token/Token pairs, and then a factory contract that you can call to deploy a new liquidity pool contract whenever you want to add a new token/token pair. So basically something like a basic Uniswap, pretty much.

I started coding a simple liquidity pool contract, but i realized that maybe this is not the kind of thing that you should completely write yourself, because a security bug in something like a DEX can be catastrophic, and if you write everything on your own bugs are very likely…

So, my question is, what would be the best route to do this? Should i use some kind of template/standard? (I dont know of any, and i dont want to fork Uniswap)? Should i write everything myself?
Is my liquidity pool and factory contract a good way of doing this?
Thanks guys