Context for Wiles defect criterion and patching

This is not a homework or a project question, just me trying to get acquainted to the subject: I am an MSc student who recently came across the Wiles defect numerical criterion (see, for example, Wiles defect of Hecke algebras via local-global arguments and Wiles defect for modules and criteria for freeness). As frequently mentioned, this is closely related to a technique Wiles developed in his proof of FLT, called patching. Following the abstract of the latter paper, the situation is this: We have a deformation ring $$R$$ associated to a modular representation $$\bar{\rho}:G_\mathbb{Q} \rightarrow GL_2(k)$$ of the absolute Galois group $$G_\mathbb{Q}$$, which arises from a complete, Noetherian, local Hecke algebra $$\mathbb{T}$$ acting on $$H^1 (X_0(N), \mathcal{O})_{\mathfrak{m}}$$, the cohomology of a modular curve $$X_0(N)$$, with coeffs in a DVR $$\mathcal{O}$$ finite flat over $$\mathbb{Z}_p$$, localized at the maximal ideal $$\mathfrak{m}$$, and with $$\mathbb{T}/\mathfrak{m} = k$$ a finite field. There is an action of the abs. Galois group on the cohomology, and it turns out $$\bar{\rho}$$ is isomorphic to a representation associated to the maximal ideal, which produces a surjection $$R \rightarrow \mathbb{T}$$, and the numerical criterion implies in favorable conditions that the cohomology is free as an $$R$$-module, and that the latter surjection is in fact a bijection of complete intersections.

The numerical invariant itself (as presented in the second paper) is defined as $$\delta_A(M) = \operatorname{rank}(M[\mathfrak{p}_A])\operatorname{length}(\Phi_A)-\operatorname{length}(\Psi_A(M))$$(as $$\mathcal{O}$$-modules), where $$\mathfrak{p}_A=\operatorname{ker}(\lambda_A:A \rightarrow \mathcal{O}$$,a surjection from a Noetherian local ring to a DVR), $$M$$ a finite $$A$$-module, $$M[\mathfrak{p}_A]$$ the $$\mathfrak{p}_A$$-torsion submodule of $$M$$, $$\Phi_A = \mathfrak{p}_A/\mathfrak{p}^2_A$$ and $$\Psi_A(M)=\frac{M}{M[\mathfrak{p}_A]+M[A[\mathfrak{p}_A]]}$$.

I've had good introductions to most areas needed to try and make sense of this, except modular representations, but I would be grateful if someone could clarify the following facts (Edited to reduce number of questions):

How do the Hecke algebra (generated by Hecke operators and diamond operators) and the Galois group act on the cohomology, and how does the surjection $$R \rightarrow \mathbb{T}$$ arise in this context, and why is it so important that this is actually a bijection?

I genuinely apologize for the long post, and please do not feel obliged to write long answers. If the post is irrelevant, please delete it.

• In general, it's better to ask just a single question in a post (e.g., see meta.mathoverflow.net/q/2666/6518 though it's not a rule). In your case, I'd recommend boiling your post down to one or maybe 2 closely related questions, and then based on responses you can ask separate questions on other parts later. Feb 10, 2023 at 0:17
• ... and I would suggest that you look at text discussing Taylor-Wiles, where you should find some answers to the above (and many more interesting things. Like "Modular Forms and Fermat’s Last Theorem". Editors: Gary Cornell, Joseph H. Silverman, Glenn Stevens. Springer 97. Feb 10, 2023 at 9:13
• @Kimball Thank you, edited accordingly Feb 10, 2023 at 15:48
• @ChrisWuthrich Thank you so much for the reference, I have just started reading it and it seems really helpful Feb 10, 2023 at 15:49