Purpose To address the issues of low localization and mapping accuracy, as well as map ghosting and drift, in indoor degraded environments using light detection and ranging-simultaneous localization and mapping (LiDAR SLAM), a real-time localization and mapping system integrating filtering and graph optimization theory is proposed. By incorporating filtering algorithms, the system effectively reduces localization errors and environmental noise. In addition, leveraging graph optimization theory, it optimizes the poses and positions throughout the SLAM process, further enhancing map accuracy and consistency. The purpose of this study resolves common problems such as map ghosting and drift, thereby achieving more precise real-time localization and mapping results. Design/methodology/approach The system consists of three main components: point cloud data preprocessing, tightly coupled inertial odometry based on filtering and backend pose graph optimization. First, point cloud data preprocessing uses the random sample consensus algorithm to segment the ground and extract ground model parameters, which are then used to construct ground constraint factors in backend optimization. Second, the frontend tightly coupled inertial odometry uses iterative error-state Kalman filtering, where the LiDAR odometry serves as observations and the inertial measurement unit preintegration results as predictions. By constructing a joint function, filtering fusion yields a more accurate LiDAR-inertial odometry. Finally, the backend incorporates graph optimization theory, introducing loop closure factors, ground constraint factors and odometry factors from frame-to-frame matching as constraints. This forms a factor graph that optimizes the map’s poses. The loop closure factor uses an improved scan-text-based loop closure detection algorithm for position recognition, reducing the rate of environmental misidentification. Findings A SLAM system integrating filtering and graph optimization technique has been proposed, demonstrating improvements of 35.3%, 37.6% and 40.8% in localization and mapping accuracy compared to ALOAM, lightweight and ground optimized lidar odometry and mapping and LiDAR inertial odometry via smoothing and mapping, respectively. The system exhibits enhanced robustness in challenging environments. Originality/value This study introduces a frontend laser-inertial odometry tightly coupled filtering method and a backend graph optimization method improved by loop closure detection. This approach demonstrates superior robustness in indoor localization and mapping accuracy.