Skip to main content

Overview

KiCad is organized as a monorepo with modular components, each serving specific purposes in the EDA workflow. The codebase follows a clear separation between core libraries, common utilities, application modules, and third-party dependencies.

Top-Level Directory Structure

Core Application Modules

eeschema/

Schematic editor application containing:
  • Symbol libraries and management
  • Schematic capture tools
  • Electrical rules checking (ERC)
  • Bill of materials (BOM) generation
  • Netlist generation
Key subdirectories:
  • dialogs/ - UI dialogs specific to schematic editing
  • sim/ - SPICE simulation integration
  • tools/ - Interactive editing tools
  • widgets/ - Custom UI widgets for schematic editor

pcbnew/

Printed circuit board editor containing:
  • PCB layout and routing tools
  • Design rule checking (DRC)
  • Footprint libraries and management
  • 3D visualization integration
  • Manufacturing output generation
Key subdirectories:
  • router/ - Interactive and automatic routing engine
  • drc_engine/ - Design rule validation
  • tools/ - PCB editing tools
  • generators/ - PCB generators (teardrops, etc.)

3d-viewer/

Standalone 3D visualization module:
  • OpenGL-based 3D rendering
  • STEP/VRML model loading
  • Ray tracing capabilities
  • Export to various 3D formats

gerbview/

Gerber and drill file viewer:
  • Multi-layer Gerber visualization
  • Excellon drill file support
  • Manufacturing file verification

cvpcb/

Component-to-footprint assignment tool:
  • Interactive footprint selection
  • Filtering and searching capabilities
  • Library browsing

pagelayout_editor/

Drawing sheet (title block) editor:
  • Custom title block design
  • Template management
  • Variable substitution support

pcb_calculator/

Electrical calculator utilities:
  • Transmission line calculations
  • Component value calculators
  • PCB fabrication parameters

bitmap2component/

Bitmap to footprint/symbol converter:
  • Image import and vectorization
  • Footprint generation from artwork
  • Symbol creation from images

kicad/

Project manager application:
  • Project file management
  • Application launcher
  • Project tree view
  • Version control integration

Libraries and Utilities

libs/

Core reusable libraries independent of EDA functionality: core/ - Base utilities with no KiCad dependencies:
  • base64.cpp - Base64 encoding/decoding
  • utf8.cpp - UTF-8 string handling
  • observable.cpp - Observer pattern implementation
  • profile.cpp - Performance profiling utilities
  • version_compare.cpp - Semantic version comparison
kimath/ - Mathematical algorithms:
  • Geometry primitives (points, vectors, boxes)
  • Polygon operations
  • Coordinate transformations
  • Collision detection
  • Bezier curve calculations
kiplatform/ - Platform abstraction layer:
  • Operating system specific functionality
  • File system operations
  • UI integration (GTK, macOS, Windows)
  • Hardware acceleration detection
sexpr/ - S-expression parser:
  • Used for KiCad’s native file formats
  • Fast serialization/deserialization
  • Streaming support
kinng/ - NNG (nanomsg) wrapper:
  • IPC communication for API
  • Message queue implementation
  • Request/response patterns

common/

Shared code used across all KiCad applications: Key components:
  • tool/ - Tool framework (actions, events, managers)
  • gal/ - Graphics abstraction layer (OpenGL, Cairo)
  • view/ - Canvas and viewport management
  • widgets/ - Reusable UI components
  • io/ - File format parsers and writers
  • drawing_sheet/ - Title block rendering
  • font/ - Font rendering (stroke and outline fonts)
  • plotters/ - Output format generators (PDF, SVG, PS, DXF)
  • settings/ - Configuration management
  • git/ - Version control integration
  • database/ - Database library support
Architecture classes:
  • kiway.cpp - Application communication bus
  • kiface_base.cpp - DSO/DLL interface implementation
  • pgm_base.cpp - Program lifecycle management
  • eda_base_frame.cpp - Base window framework
  • project.cpp - Project data structure

include/

Public header files and interfaces:
  • Organized by subsystem
  • Defines public APIs
  • Contains interface declarations
  • Template implementations
Key directories:
  • tool/ - Tool framework headers
  • gal/ - Graphics API headers
  • view/ - Visualization headers
  • font/ - Font rendering headers
  • plugins/ - Plugin interfaces

External Integrations

scripting/

Python scripting support:
  • SWIG bindings generation
  • Python API exposure
  • Plugin framework
  • Interactive Python console
Files:
  • kicadplugins.i - SWIG interface definition
  • python_scripting.cpp - Python integration
  • python_manager.cpp - Plugin lifecycle

api/

Modern IPC API (introduced in KiCad 8):
  • proto/ - Protocol Buffer definitions
    • common/ - Shared message types
    • board/ - PCB-specific commands
    • sch/ - Schematic-specific commands
  • schemas/ - JSON schemas for validation
Architecture:
  • Uses Protocol Buffers for serialization
  • NNG for transport layer
  • Supports external tools and automation

plugins/

3D model import plugins:
  • 3d/idf/ - IDF (Intermediate Data Format)
  • 3d/oce/ - STEP file support via OpenCASCADE
  • 3d/vrml/ - VRML/WRL model import

Build and Infrastructure

cmake/

CMake build system modules:
  • Platform detection
  • Dependency finding
  • Compiler configuration
  • Package creation

thirdparty/

Vendored third-party libraries:
  • Modified or pinned versions
  • Libraries not available in standard package managers
  • Platform-specific dependencies
Examples:
  • libcontext/ - Coroutine support
  • potrace/ - Bitmap tracing
  • fmt/ - String formatting
  • nlohmann_json/ - JSON parsing

qa/

Quality assurance and testing:
  • unittests/ - Unit test suites
  • qa_utils/ - Testing utilities
  • pcbnew_utils/ - PCB testing helpers
  • eeschema_utils/ - Schematic testing helpers

tools/

Development and build utilities:
  • Code formatting tools
  • Documentation generators
  • Build helpers
  • Migration scripts

utils/

Utility applications:
  • IDF tools
  • STEP exporters
  • File format converters

Resources

resources/

Non-code assets:
  • bitmaps_png/ - UI icons and images
  • project_template/ - Default project templates
  • Platform-specific packaging files

demos/

Example projects:
  • Reference designs
  • Feature demonstrations
  • Tutorial projects

translation/

Internationalization:
  • .po files for various languages
  • Managed through Weblate
  • Language resource compilation

Build Targets Organization

From CMakeLists.txt, the build order is:
  1. Core libraries (libs/)
  2. Resources (resources/)
  3. Third-party (thirdparty/)
  4. Common library (common/)
  5. Scripting (scripting/)
  6. API (api/) - if KICAD_IPC_API enabled
  7. Applications:
    • 3D viewer
    • Eeschema
    • Gerbview
    • Pcbnew
    • Page layout editor
    • Bitmap converter
    • PCB calculator
  8. Plugins (plugins/) - must build before kicad
  9. CvPCB - depends on pcbnew
  10. KiCad project manager - depends on pcbnew, eeschema, api
  11. Tools and utilities
  12. QA tests - if KICAD_BUILD_QA_TESTS enabled

File Organization Patterns

KiCad follows consistent patterns:
  • Headers in include/: Public interfaces
  • Implementation in module directories: Private implementation
  • Dialogs: Separate subdirectory with UI files
  • Tools: Dedicated tools/ subdirectory for interactive tools
  • Widgets: Reusable UI components in widgets/
  • IO: File format handlers in io/ or module-specific locations

Dependency Hierarchy

libs/core (no dependencies)

libs/kimath, kiplatform, sexpr

common (depends on libs/*)

scripting, api

application modules (eeschema, pcbnew, etc.)

kicad project manager

Module Independence

Each major application (eeschema, pcbnew, etc.) is built as a separate DSO/DLL:
  • Can be loaded independently
  • Communicates via KIWAY interface
  • Shares common code through libcommon
  • Enables Python integration per module
  • Supports separate testing

See Also

Build docs developers (and LLMs) love