This article presents an educational code written in FreeFEM, based on the concept of topological derivative together with a level-set domain representation method and adaptive mesh refinement processes, to perform compliance minimization in structural optimization. The code is implemented in the framework of linearized elasticity, for both plane strain and plane stress assumptions. As a first-order topology optimization algorithm, the topological derivative is in fact used within the numerical procedure as a steepest descent direction, similar to methods based on the gradient of cost functionals. In addition, adaptive mesh refinement processes are used as part of the optimization scheme for enhancing the resolution of the final topology. Since the paper is intended for educational purposes, we start by explaining how to compute topological derivatives, followed by a step-by-step description of the code, which makes the binding of the theoretical aspects of the algorithm to its implementation. Numerical results associated with three classic examples in topology optimization are presented and discussed, showing the effectiveness and robustness of the proposed approach.