An algorithm implemented in an open-source python library was developed for building periodic coincidence site lattice (CSL) grain boundary models in a universal fashion. The software framework aims to generate tilt and twist grain boundaries from cubic and tetragonal crystals for ab-initio and classical atomistic simulation. This framework has two useful features: i) it can calculate all the CSL matrices for generating CSL from a given Sigma ({Sigma}) value and rotation axis, allowing the users to build the specific CSL and grain boundary models; ii) it provides a convenient command line tool to enable high-throughput generation of tilt and twist grain boundaries by assigning an input crystal structure, {Sigma} value, rotation axis, and grain boundary plane. The developed algorithm in the open-source python library is expected to facilitate studies of grain boundary in materials science. The software framework is available on the website: aimsgb.org.