NSDocument is the base class for document-based applications in Cocoa and provides the core functionality for managing documents and windows. It integrates with NSWindowController to coordinate opening and closing documents and windows. NSDocument also manages document versions through integration with NSFileVersion.