How can I generalize the solution if the modulus is not co-prime. I am familiar with the following.
$\newcommand{\lcm}{\mathrm{lcm}}$Suppose you have a system of two congruences $$\tag{two} \begin{cases} x \equiv a \pmod{m}\\ x \equiv b \pmod{n}\\ \end{cases} $$ This is soluble iff $\gcd(m, n) \mid a - b$. If this is the case, first find, using Euclid's algorithm, $u, v$ such that $$ m u + n v = \gcd(m, n). $$ Multiply by $$ \lambda = \frac{a - b}{\gcd(m, n)} $$ to get $$ m (u \lambda) + n (\lambda v) = a - b, $$ and now a solution is $$ x = a - m (u \lambda) = b + n (\lambda v) = \sigma, $$ and all solutions are the numbers $$\tag{one} x \equiv \sigma \pmod{\lcm(m, n)} $$ If you have more than two equations, use this method on the first two to reduce (two) to (one), so you have an equation less. Repeat.
I do not know if gcd(m, n) | (a - b), is there any possible way to determine a general solution. Thanks in advance
Let $m<n$ WLOG. If $m\mid n$, then the solution is $x\equiv b\mod n$ provided $b\equiv a\pmod m$ and no solution otherwise. So you need $b-a\equiv 0\pmod m$ and $m=d$.
If $gcd(m,n)=d<m$, then $gcd(m/d, n/d)=1$. By CRT there exists unique $x<mn/d^2$ with $x\equiv a\pmod{m/d}, x\equiv b\pmod{n/d}$. So the solution modulo $mn$ would be $x+sn/d$ for some $s$. So we should have $x+sn/d\equiv b\pmod n$, subtracting $b$,
$x-b+sn/d\equiv 0 \pmod n$. Divide by $n/d$:
$t+s\equiv 0 \pmod d$ where $x-b=t(n/d)$.
Also $x+sn/d\equiv a\pmod m$, so $x-a+sn/d\equiv 0 \pmod m$.
Both $x-a$ and $m$ are divisible by $m/d$, so $sn/d$ is divisible by $m/d$, and since $gcd(m/d, n/d)=1$, $s=km/d$ for some $k$.
Hence $x-a+kmn/d^2\equiv 0\pmod m$. Thus $tn/d+b-a+kmn/d^2\equiv 0 \pmod m$. Reduce everything modulo $d$, use that $t\equiv -s=-km/d\pmod d$ and $m\equiv 0\pmod d$ we have $b-a\equiv 0\pmod d$ as required.