A groupoid is a small category in which every morphism is an isomorphism. They arise throughout mathematics, e.g. in guise of fundamental groupoids in the theory of covering spaces, holonomy groupoids in the theory of foliations or Lie groupoids in mathematical physics. For groupoids in the sense of universal algebra, i.e., a set with a binary operation, please use the (magma) tag. Also, use other tags such as monoid or category-theory, if needed.
A groupoid (in the sense of category theory) is a small category in which every morphism is an isomorphism. Groupoids can equivalently define as a set with a partial (binary) operation and an unary operation subject to some equation. Hence this concept should not be confused with that of Magma involving a globally defined binary operation.
Groupoids are extremely flexible and connected with many other bracnches of mathematics. For example
A groupoid with one object is uniquely determined by its automorphism group and vise versa. Hence, any group may be regarded as a one-object groupoid and therefore one way to understand the concept of groupoids is, they are groups with multiple objects (for example, isomorphisms between a set of graphs form a groupoid). This can make more precise by the equivalence between category of connected groupoids and the category of groups. Also, information contained in other semi-algebraic structures can easily transform to groupoids. For instance, every inverse semigroup is equivalently an inductive groupoid.
The nerve functor $N:\mathbf{Grpd} \to \mathbf{sSet}$ embeds $\mathbf{Grpd}$ as a full subcategory of the category of simplicial sets. The nerve of a groupoid is always Kan complex. On the other hand, this functor has a left adjoint functor called the "Geometric realization". Due to the Dold-Kan correspondence (equivalence between nonnegatively gradedchain complexes and simplicial abelian groups), groupoids are fundamental to homological/homotopical algebra.
The forgetful functor $\mathbf{Grpd}\to\mathbf{Cat}$ has both left and right adjoint functorss. The left adjoint $\mathcal{L}$ freely invert all existing morphisms of a category, while the right right adjoint $\mathcal{R}$ extract the (maximal) subcategory of all isomorphisms, called "core groupoid" of a category.
Moreover, groupoids naturally arise throughout mathematics, e.g. in guise of fundamental groupoids in the theory of covering spaces (whose objects are points of the spaces and morphisms are path homotopy classes with concatenation as groupoid multiplication etc.), action groupoid representing a group action (in general any equivalence relation), holonomy groupoids in the theory of foliations or Lie groupoids in mathematical physics. Another important example is the (absolute) Galois groupoid $\operatorname{Gal}(k)$ of a field $k$ whose objects are algebraically closed (or separably closed if $\operatorname{char}(k)\neq0$) extensions $L/k,$ whereas morphisms are isomorphisms $L\to L'$ of extensions over $k.$